Jump 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.

Featured Replies

Hi Folks,

this one has me stumped, and was wondering if anyone can offer suggestions on what is missing?

Here is the code with comments stating what is happening:

# capture selected signtype IDs

Set Variable [ $SigntypeIDs; Value: SIGNTYPE::_kg_STKeyHolder]

Go to Layout ["quote_QUOTELINEITEM" (quote_QUOTELINEITEM) ]

# loop through values and create quote line item records

# next step is there just to see values for debugging

Show Custom Dialog [sIGNTYPE::_kg_STKeyHolder]

# at this point the values are there

Loop

# next step is there just to see values for debugging

Show Custom Dialog [ GetValue ( $SigntypeIDs ; $i) ]

# at this point the values do not show

Set Variable [$i; Value: $i + 1]

Exit Loop If [ $i > ValueCount ( $SignypeIDs) ]

New Record/Request

Set Field

# this part is setting correctly

Set Field

Is this a print-out of your script, or did you type it yourself?

  • Author

Is this a print-out of your script, or did you type it yourself?

I typed it out myself

I notice at one point you typed "$SignypeIDs" instead of "$SigntypeIDs". Check your script for a similar typo.

  • Author

Ok check the original script and it looks OK with the spelling. BTW what is best way to show my script for these forums instead of retyping?

If you are on a Mac, you can do Print > Preview > Select All > Copy > Cancel, then paste it here. Not sure about Windows.

You can also post a file showing the problem.

  • Author

Thanks Comment. Here is the actual code

# capture selected signtype IDs

Set Variable [ $SigntypeIDs; Value:SIGNTYPE::_kg_STKeyHolder ]

Go to Layout [ “quote_QUOTELINEITEM” (quote_QUOTELINEITEM) ]

# loop through values and create quote line item records

Show Custom Dialog [ Message: SIGNTYPE::_kg_STKeyHolder; Buttons: “OK” ]

Loop

Show Custom Dialog [ Message: GetValue ( $SigntypeIDs ; $i ); Buttons: “OK” ]

Set Variable [ $i; Value:$i + 1 ]

Exit Loop If [ $i > ValueCount ( $SigntypeIDs) ]

New Record/Request

Set Field [ quote_QUOTELINEITEM::_kf_QuoteID; $$QuoteID ]

Set Field [ quote_QUOTELINEITEM::_kf_SignTypeID; GetValue ( $SigntypeIDs ; $i ) ]

End Loop

Enter Browse Mode

Close Window [ Current Window ]

(Edit to just move "Exit Loop step to new line" - no change to code)

I don't see why it wouldn't work. You have the Advanced version: why don't you run the script in debugger - and watch the variables in Data Viewer.

  • Author

Strange huh! Yeah I do have advance and have run the debugger and the viewer and that is the result I get as noted that the values drop at that point.

What point is that?

  • Author

I will try to explain below:

# loop through values and create quote line item records

Show Custom Dialog [ Message: SIGNTYPE::_kg_STKeyHolder; Buttons: “OK” ]

- the values show up here - so the global field has 2 values right now of

448

449

and the dialog displays them as

448

449

Loop

Show Custom Dialog [ Message: GetValue ( $SigntypeIDs ; $i ); Buttons: “OK” ]

- the dialog displays nothing at this point, so something is not right at this point, but I'm not sure what it is

  • Author

OK, looks like something is working, but it maybe the calculation that goes to the global field for the sign type IDs is inserting extra pilcrows at the beginning of the list, so this shows up as blank items when it sets the field. Let me do more checking here to see what is going on. Thanks for your help comment at least I now know the coding was correct for what I showed.

  • Author

So, I checked and there is definitely an extra pilcrow at the beginning of the list of IDs in the global key field. The calc used for the selection and deselection of a signtype to the global field is:

Set Field [sIGNTYPE::_kg_STKeyHolder;

Case (

FilterValues ( SIGNTYPE::_kg_STKeyHolder; SIGNTYPE::__kp_STid )

; Substitute ( ¶ & SIGNTYPE::_kg_STKeyHolder & ¶ ; ¶ & SIGNTYPE::__kp_STid & ¶ ; ¶)

; SIGNTYPE::_kg_STKeyHolder & ¶ & SIGNTYPE::__kp_STid )]

Conditional Format (to change highlight color) is

FilterValues ( SIGNTYPE::_kg_STKeyHolder ; SIGNTYPE::__kp_STid )

My question is how do I change the code to strip the extra pilcrow at the beginning so I don't get that extra blank value entered when the script is run to created the quoteline items?

Loop

Show Custom Dialog [ Message: GetValue ( $SigntypeIDs ; $i ); Buttons: “OK” ]

Set Variable [ $i; Value:$i + 1 ]

This will show a value only on the second iteration and on (after $i gets a value). To get the dialog reflect what's really happening, try:

Loop

Set Variable [ $i; Value:$i + 1 ]

Exit Loop If [ $i > ValueCount ( $SigntypeIDs) ]

Show Custom Dialog [ Message: GetValue ( $SigntypeIDs ; $i ); Buttons: “OK” ]

New Record/Request

...

  • Author

OK, did what you said and tried some other things.

What is happening is that an extra pilcrow (paragraph return) is at the top of the list in the global field. Others can show up in different spots depending on the selecting and deselecting of the signtypes. So if I picked two items and did no deselecting/ reselecting I'm getting this in the global field:

458¶

459¶

If I select & deselect multiple items it can look like this:

448¶

450¶

452¶

This is the button formula that is setting the IDs in the global key field:

Set Field [sIGNTYPE::_kg_STKeyHolder;

Case (

FilterValues ( SIGNTYPE::_kg_STKeyHolder; SIGNTYPE::__kp_STid )

; Substitute ( ¶ & SIGNTYPE::_kg_STKeyHolder & ¶ ; ¶ & SIGNTYPE::__kp_STid & ¶ ; ¶)

; SIGNTYPE::_kg_STKeyHolder & ¶ & SIGNTYPE::__kp_STid )]

So, I guess the trick is how to strip out the extra ¶s that are being passed to the script variable and yet retain the count and enter the IDs correctly.

I have heard of people using the pipe character (|) instead, but still not sure of procedure to substitute that when it comes time to pass the variable IDs to the script.

Try =

Case (

IsEmpty ( FilterValues ( item ; listOfValues ) ) ; 

List ( listOfValues ; item ) ;



Let (

excl = Substitute ( ¶ & listOfValues & ¶ ; ¶ & item & ¶ ; ¶ )

;

Middle ( excl ; 2 ; Length ( excl ) - 2 )

)



)

  • Author

I'm confused...would I use this on the button script that sets the global multi key field or put this in the script when the items are going to be added to the quote line items table?

The former.

  • Author

Awesome Comment that worked!

What does the "excl" in the code do out of curiosity?

Nothing - it's just the name of a temp variable (short for "exclude").

Create an account or sign in to comment

Important Information

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

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.