Formula Help - Struggling with conditions

I have the following formula actioned by a button on a form:

@If( Fitters_Comments != "";
     @Do(   FIELD WIP_Date := @Now;
      FIELD WIP_Fitter := @Name([CN]; @UserName);
                FIELD status := "Pending";
      FIELD Fitters_Comments_1 := Fitters_Comments_1 + WIP_Fitter + " @ " + @Text(WIP_Date) + " - " + Fitters_Comments + @NewLine ;
      FIELD Fitters_Comments :="";
      @Command( [RefreshHideFormulas] ));

     @Do(@Command([EditGotoField]; "Fitters_Comments" );
             @Command([EditSelectAll]);
             @Prompt( [Ok]; "Not Updated"; "Please enter a valid comment and try again" ) ) )

I need to add the following conditions to it:

If the status field = "Awaiting Parts" when the button is pressed I need a message box to pop up to check whether parts are still on order. If yes is pressed I want the status field to remain as "Awaiting Parts" If no is pressed I want the status field to change to "Pending"

I figure I need to take out the 4th line: FIELD status := "Pending";
and somewhere put in a @Dowhile "status =....@prompt.....@success;@failure?

I can't seem to figure this out... I bet I kick myself when I see the answer!

Thanks for your help!
LVL 21
shuboarderAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mbonaciCommented:
Hi shuboarder,
use @SetField function, FIELD works only if it's the first statement in line (not in Do, If, While block)

Hope this helps,
Marko
shuboarderAuthor Commented:
mbonaci - Thanks for the quick reply!

I tried using @setfield but I kept getting an error message about passing arguments to @functions or something.

Any ideas on how it should look?


mbonaciCommented:
shuboarder,

@If( status = "Awaiting Parts";
    @Do(
        @If( 0 = @Prompt([YESNO]; "Check parts?"; "Are parts still on order");
            @SetField( "Status"; "Pending" );
            @Return("") )
        );
    @Return("") )


Hope this helps,
Marko

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

shuboarderAuthor Commented:
Ok, that's great. However now if the status isn't "Awaiting Parts" it doesn't change to "Pending"
i.e. If the status is "Active" and the button is pressed I still need status to change to pending. (just don't need a prompt to confirm.

Does that make sense?

This is the code so far:

@If( Fitters_Comments != "";
     @Do(   FIELD WIP_Date := @Now;
      FIELD WIP_Fitter := @Name([CN]; @UserName);
      FIELD Fitters_Comments_1 := Fitters_Comments_1 + WIP_Fitter + " @ " + @Text(WIP_Date) + " - " + Fitters_Comments + @NewLine ;
FIELD Fitters_Comments :="";

@If( status = "Awaiting Parts";
    @Do(
        @If( 0 = @Prompt([YesNo]; "Status"; "Are parts still required to complete this job?");
            @SetField( "Status"; "Pending" );
            @Return("") )
        );
    @Return("") );

@Command( [RefreshHideFormulas] ));

     @Do(@Command([EditGotoField]; "Fitters_Comments" );
             @Command([EditSelectAll]);
             @Prompt( [Ok]; "Not Updated"; "Please enter a valid comment and try again" ) ) )
mbonaciCommented:
shuboarder,
I think you could've done this yourself:

@If( status = "Awaiting Parts";
    @Do(
        @If( 0 = @Prompt([YesNo]; "Status"; "Are parts still required to complete this job?");
            @SetField( "Status"; "Pending" );
            @Return("") )
        );
    @SetField( "Status"; "Pending" ) );


You'll never learn this way...
Marko
shuboarderAuthor Commented:
:(

- You always say that!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.