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?
 
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
0
 
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
0
 
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?


0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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" ) ) )
0
 
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
0
 
shuboarderAuthor Commented:
:(

- You always say that!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.