Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Simple Script structure

Featured Replies

Users work in Credit Memos in a new window. I want only a Close button. I want the script to test that each piece is done and branch depending upon the results. A Memo can't be Approved until it is Finished. It can't be Processed until it has been Approved. If everything is done, I want the window to simply close.

As I list out the script, I realize there are many ways to write it. But I want elegant and I keep getting twisted in Else If[] and how to group the steps. Psuedo-script below:

If [ Finished and Approved and Processed ]

  Close Window

  Halt Script

Else If [ Approved ]

  Show Custom Dialog [ No ; Yes ; "Memo hasn't been Processed. Do now?"]

    If [ Get ( LastMessageChoice ) = 2 ]

      Set Field [ ProcessedBy ; Get ( AccountName ) ]

      Set Field [ ProcessDate ; Get ( CurrentDate ) ]

    End If

Else If [ Finished ]

  Show Custom Dialog [ No ; Yes ; "Memo hasn't been Approved. Do now?"]

    If [ Get ( LastMessageChoice ) = 2 ]

      Set Field [ ApprovedBy ; Get ( AccountName ) ]

      Set Field [ ApproveDate ; Get ( CurrentDate ) ]

    End If

Else

  Show Custom Dialog [ No ; Yes ; "Is this Memo Finished?"]

    If [ Get ( LastMessageChoice ) = 2 ]

      Set Field [ FinishedBy ; Get ( AccountName ) ]

      Set Field [ FinishDate ; Get ( CurrentDate ) ]

End If

    Close Window

I am asking because I can use a Case() statement within the Custom Dialog to combine them. But I'll still have to branch on the results because I'm using Set Field[]. The script has more tests but I used these three because they follow a sequence and I thought it would be clearer for reviewing. Ideas appreciated. I'm not totally comfortable with Else If[] yet either. :wink2:

LaRetta

I don't have a problem with this.

While I strive for elegance and brevity in scripts, theese goals are balanced with "transparency" which is the ability to easily see what the script does and how it does it.

A question: is the Halt Script step after the Close Window step necessary? Will it ever run?

  • Author

Hi there Vaughan!

In this instance, I have another running script which must be stopped; otherwise I would use Exit Script[]. Thank you for the input! :wink2:

L

I'd personally use reps to make it easier... but otherwise maybe just get rid of the cust dialogs?


If [ Finished and Approved and Processed ]

  Close Window

  Halt Script

End If

Set Variable[ $message ; Case( Approve ; "Memo hasn't been processed. Do now?" ; Finished ; "Memo hasn't been Approved. Do now?" ;"Is this Memo Finished?" ) ]

Show Dialog[ No ; Yes ; $message ]

Set Variable[ $choice ; Get(LastMessageChoice) ]

If [ $choice = 2 and Approved ]

      Set Field [ ProcessedBy ; Get ( AccountName ) ]

      Set Field [ ProcessDate ; Get ( CurrentDate ) ]

Else If [ $choice = 2 and Finished ]

      Set Field [ ApprovedBy ; Get ( AccountName ) ]

      Set Field [ ApproveDate ; Get ( CurrentDate ) ]

Else If[ $choice = 2 ]

      Set Field [ FinishedBy ; Get ( AccountName ) ]

      Set Field [ FinishDate ; Get ( CurrentDate ) ]

End If

Close Window

  • Author

Thanks! Yes, this was the other direction I was considering. But I'd write it without the variables as:

If [ Finished and Approved and Processed ]

  Close Window

  Halt Script

End If

Show Dialog[ No ; Yes ; "Memo hasn't been " & Case ( not Processed ; "Processed" ; not Approved ; "Approved"; "Finished" ) & ". Do it now?"]

If [ Get ( LastMessageChoice ) = 2 and not Processed ]

      Set Field [ ProcessedBy ; Get ( AccountName ) ]

      Set Field [ ProcessDate ; Get ( CurrentDate ) ]

Else If [  Get ( LastMessageChoice ) = 2 and not Approved ]

      Set Field [ ApprovedBy ; Get ( AccountName ) ]

      Set Field [ ApproveDate ; Get ( CurrentDate ) ]

Else 

      Set Field [ FinishedBy ; Get ( AccountName ) ]

      Set Field [ FinishDate ; Get ( CurrentDate ) ]

End If

Close Window

It's getting better!

Edited by Guest
Added Not to tests

... Lol, i like variables -- no it's just a habit, i usually use message choices down the track in a script (sorry).

  • Author

No prob, Genx. I fight the old habit of creating globals to hold my work. :girlgiggle:

I see I also copy/pasted the wrong Set Fields [] into it; but I'm sure it's clear to everyone. I'll correct it anyway. :wink2:

Edited by Guest

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.