Jump to content

Script Step doesn't accept parameter


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

Recommended Posts

This is a problem with passing a parameter to a script to tell it which layout to use.

I have created a script that opens a Layout and Sets a field in that layout. Simple.

Now imagine a Layout with a half-dozen buttons. Each button runs this same script, but the Layout it goes to is different for each button.

I could make 6 copies of the script, modifying each one to change the name of its destination layout.

But I’d prefer to write the script once, then have each button pass a parameter with the name of its destination layout.

The Script step “Go to Layout” accepts a parameter to tell it which layout to go to.

The Script step “Set Field” does not.

So, using parameter passing, I can get to the proper layout, but, once I’m there, I can’t set a field on that layout.

Any ideas?

Link to comment
Share on other sites

It sounds like you're trying to pass multiple parameters in one script. To do this you need to create a delimited list of parameters and pull them out using text manipulation etc.

One easy way to do this is to pass a list of parameters as a return-delimited list, and use the MiddleValues() function together with Get(ScriptParameter) to pull out the right parameter when you need it.

Link to comment
Share on other sites

The Script step “Go to Layout” accepts a parameter to tell it which layout to go to.

The Script step “Set Field” does not.

So, using parameter passing, I can get to the proper layout, but, once I’m there, I can’t set a field on that layout.

If I understand you correctly you want to pass parameters to your script that indicate not only what layout to navigate to but also the name of a field to set. A problem with the "Set Field" script step is that it does not allow the target field to be specified through a calculation. This is the subject of an old post and it includes a couple of hacks. See the link for more details: Wants and Wishes

Link to comment
Share on other sites

A problem with the "Set Field" script step is that it does not allow the target field to be specified through a calculation.

Well it's not too complicated to make:

If [ PatternCount ( FieldNames ( Get ( FileName ) ; Get ( LayoutName ) ) ; LeftValues(Get ( ScriptParameter );1) ) ] 

     Go to Field [  ] [ Select/perform ] 

     Go to Next Field 

     Loop 

          Exit Loop If [ Get ( ActiveFieldName ) & "¶" = LeftValues(Get ( ScriptParameter );1) ] 

          Go to Next Field 

     End Loop 

     Set Field [ Substitute ( Trim ( Substitute ( RightValues ( Get ( ScriptParameter ) ; 1 ) ; "¶" ; " " ) ) ; " " ; "¶" ) ] 

     Commit Records/Requests [ Skip data entry validation; No dialog ] 

End If 

First value in the paramter is the fieldname you wish to send a value to and the second is the value in itself. Only thing missing is to put the scriptparamters to each button, the script is the one and same.

--sd

Link to comment
Share on other sites

This topic is 6680 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.