datalink Posted March 29, 2011 Posted March 29, 2011 Is it possible to use a script parameter containing the name of the field to be modified into the first parameter of the Set Field By Name step? In other words I'd like to use the same Set Field By Name step to modify different fields by passing the name of the field to be modified into the script via a script parameter. It seems like this should be possible, but I'm not having any luck. Thanks in advance.
comment Posted March 29, 2011 Posted March 29, 2011 Yes, it is possible - as long as the name is passed as a text string, not as a reference to the field (which evaluates to the contents of the field).
datalink Posted March 29, 2011 Author Posted March 29, 2011 Hmm...so I'm no longer getting error 102, so it is finding the field, but its not seeming to modify it. I think now the second parameter needs a caress. Set Field By Name[Get(ScriptParameter) ; Let( X = Get(ScriptParameter) ; Case (X= "N" or IsEmpty (X) ; "Y" ; "N"))] The script parameter is being passed as: "CON__Contacts.tog::z_CourtesyCallFlag"
comment Posted March 29, 2011 Posted March 29, 2011 If your parameter is "CON__Contacts.tog::z_CourtesyCallFlag", then it will never be equal to "N" or empty. What exactly are you trying to do here?
datalink Posted March 29, 2011 Author Posted March 29, 2011 Ungh....of course. I see the problem, but still am unsure about the solution. I want to pass the name of the field to be modified into the script via the script parameter to be used in the first parameter of the Set Field By Name step. The second parameter I want to be a calculation that checks to see if that same field's content is currently empty or "N" and if so to modify that same fields contents to "Y", but if that same field's contents are "Y" to change it to "N". Essentially, the scirpt is supposed to just be toggling the contents of the field whose name is passed via the script parameter. GetField(Get(ScriptParameter)) makes it work. You have been so helpful many times in the past as well as this one. Thanks so much.
comment Posted March 29, 2011 Posted March 29, 2011 Wouldn't it be simpler to make each field a button with a single SetField[] script step? Then you wouldn't need a script at all. The way you have it now, you need to use: GetField ( Get ( ScriptParameter ) ) to retrieve the field's contents. Note also that the smart way to define the parameter is = GetFieldName ( YourTable::YourField ) This way you can rename the field without breaking the script. Finally, it's best to use Number fields as status/flag fields. Use 1 for True, and 0 (or empty) for False. Toggle by setting the field to 'not the field'.
datalink Posted March 29, 2011 Author Posted March 29, 2011 I'm using a script because there is more to do in the logic than just toggle the field. These were really helpful suggestions. Thanks so much.
Recommended Posts
This topic is 4988 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 accountSign in
Already have an account? Sign in here.
Sign In Now