Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 4940 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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

Posted

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?

Posted

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.

Posted

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)

Posted

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.

Posted

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.

Posted

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

Posted

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.

Posted

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?

Posted

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

...

Posted

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.

Posted

Try =

Case (

IsEmpty ( FilterValues ( item ; listOfValues ) ) ; 

List ( listOfValues ; item ) ;



Let (

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

;

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

)



)

Posted

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?

This topic is 4940 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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