- parms.docx
- (37.44 KiB) Downloaded 151 times
multiple parms with script:
-
- Experienced User
- Posts: 147
- Joined: Tue Jun 17, 2014 4:00 pm
- First Name: Patti
- Last Name: Bednarz
- Company Name: McGard
- State / Province: New York
- Country: United States
- Contact:
multiple parms with script:
I am trying to substitute multiple parms into a query select for a data-b
ase driven drop-down. I am unable to substitute multiple parameters using the "script: technique. I have also found that if I am mixing "script" with fields bound to program variables, the script parm must be referenced first or the other parms are not recognized. My example shows 2 parms, but ideally I will be using more... Can I do this, or is there still an issue with parameter values 2,3 ect. ? Thank you, Patti-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: multiple parms with script:
Using "script:" as you have done is good for parameters that you wish to modify in JavaScript (such as when you want to reload a dropdown without going back to the RPG program, as you have done in some of your previous questions)
If you plan to populate the values directly from RPG variables, and won't need to change them from JavaScript, then binding directly to the RPG variables will be more secure and perform better.
I would not attempt to mix these techniques in the same SQL statement. Either use all "script:" or all RPG-bound for each statement.
Otherwise, what you're doing looks correct to me. You say that this isn't working?
If you plan to populate the values directly from RPG variables, and won't need to change them from JavaScript, then binding directly to the RPG variables will be more secure and perform better.
I would not attempt to mix these techniques in the same SQL statement. Either use all "script:" or all RPG-bound for each statement.
Otherwise, what you're doing looks correct to me. You say that this isn't working?
-
- Experienced User
- Posts: 147
- Joined: Tue Jun 17, 2014 4:00 pm
- First Name: Patti
- Last Name: Bednarz
- Company Name: McGard
- State / Province: New York
- Country: United States
- Contact:
Re: multiple parms with script:
HI Scott,
Yes, it does not work when I need to substitute more than one parameter using the script technique. The Developer Tools do not show a second parameter. I only see "p1". I seem to recall you saying there was an issue with using applyproperty with choice parameter value 2,3,4 etc.
When I mix techniques, the "script" will only be recognized if it is the first parameter (I did this to help me troubleshoot). That is what made me think there may be an issue with parameters 2,3 4. I have no problems when I use bound program fields with parameters 2,3 4. In my scenario, I need to update my sql statement based on the values from 3 drop downs. I have a department, machine, and process drop-down which should drive the contents of a part number drop-down. The user has to minimally select a department. Machine and process are optional so my sql needs to be able to handle that situation. I know I can return control to the rpg and manually build the part number drop-down, but I was hoping I could use database-driven and javascript similar to what you have helped me with in the past. (I know, each time my scenario gets more complicated) ....
We are still at release 5.0.8, but I did not see any reference to the "choice parameter value 2,3 4" issue being corrected in the list of "features/fixes".
Yes, it does not work when I need to substitute more than one parameter using the script technique. The Developer Tools do not show a second parameter. I only see "p1". I seem to recall you saying there was an issue with using applyproperty with choice parameter value 2,3,4 etc.
When I mix techniques, the "script" will only be recognized if it is the first parameter (I did this to help me troubleshoot). That is what made me think there may be an issue with parameters 2,3 4. I have no problems when I use bound program fields with parameters 2,3 4. In my scenario, I need to update my sql statement based on the values from 3 drop downs. I have a department, machine, and process drop-down which should drive the contents of a part number drop-down. The user has to minimally select a department. Machine and process are optional so my sql needs to be able to handle that situation. I know I can return control to the rpg and manually build the part number drop-down, but I was hoping I could use database-driven and javascript similar to what you have helped me with in the past. (I know, each time my scenario gets more complicated) ....
We are still at release 5.0.8, but I did not see any reference to the "choice parameter value 2,3 4" issue being corrected in the list of "features/fixes".
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: multiple parms with script:
Hmm, I thought this was already fixed in version 5.0.1. I can see it in the change log ("Modify applyProperty() API so it works with multi-occurrence properties"). But, it sounds like it's not working for you.
A workaround would be to set the parameter values like this:
But, we should look into fixing the applyProperty API.
A workaround would be to set the parameter values like this:
Code: Select all
getObj("YourId").pui.properties["parameter value 2"] = "the value";
-
- Experienced User
- Posts: 147
- Joined: Tue Jun 17, 2014 4:00 pm
- First Name: Patti
- Last Name: Bednarz
- Company Name: McGard
- State / Province: New York
- Country: United States
- Contact:
Re: multiple parms with script:
Sorry Scott, but I am confused.
Would the "getobj" go on my "onchange" event for my machine drop-down? If so, what would my parameter value 2 entry look like on the data-base driven select for my part drop-down? I thought I could only code "script" or a bound program field.
Would the "getobj" go on my "onchange" event for my machine drop-down? If so, what would my parameter value 2 entry look like on the data-base driven select for my part drop-down? I thought I could only code "script" or a bound program field.
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: multiple parms with script:
It's possible that it is me who is confused, here... I thought you were saying that you had some code running applyProperty() and it was failing to apply parameter values with 2, 3, 4, etc suffixes? But you also mention "script:" which implies you have code that's directly in the "parameter value X" field to begin with, so there'd be no need/use for applyProperty() in that case. You mentioned "script:" from the start, but I guess I didn't think that was the part that was failing for some reason... like I said, maybe I'm the one who is confused :-)
The p2, p3, etc would fail to submit if the data returned from get() is blank. I would double-check that you have the ID name for get() set correctly, and that it's already set at the time the screen loads. Keep in mind that the "id" property is case-sensitive, so the id of your field must be exactly "HidMach", not "HIDMACH" or "hidmach". Since it's case-sensitive the upper/lowercase must match exactly.
As a test you could set parameter value 2 to: script: alert("HidMach=" + get("HidMach"))
with that change, the SQL definitely won't work, and the p2 definitely won't submit, however, it will bring up a popup when the screen is loading to show you what the output of get() is. This can tell you if you're getting a value from the get() or not. Once you've determined that, you would need to change it back (i.e. remove the 'alert') in order for it to work properly.
The p2, p3, etc would fail to submit if the data returned from get() is blank. I would double-check that you have the ID name for get() set correctly, and that it's already set at the time the screen loads. Keep in mind that the "id" property is case-sensitive, so the id of your field must be exactly "HidMach", not "HIDMACH" or "hidmach". Since it's case-sensitive the upper/lowercase must match exactly.
As a test you could set parameter value 2 to: script: alert("HidMach=" + get("HidMach"))
with that change, the SQL definitely won't work, and the p2 definitely won't submit, however, it will bring up a popup when the screen is loading to show you what the output of get() is. This can tell you if you're getting a value from the get() or not. Once you've determined that, you would need to change it back (i.e. remove the 'alert') in order for it to work properly.
-
- Experienced User
- Posts: 147
- Joined: Tue Jun 17, 2014 4:00 pm
- First Name: Patti
- Last Name: Bednarz
- Company Name: McGard
- State / Province: New York
- Country: United States
- Contact:
Re: multiple parms with script:
Scott, I have been under the impression that I need BOTH "applyproperty" in the OnChange, AND :Script:get" on the parameters.
I am enclosing the way I have been coding this.
OnChange event for Department drop-down
applyProperty("Partselect", "choices parameter value", get("Deptselect"));
applyProperty("Partselect", "field type", "select box");
OnChange even for Machine drop-down
applyProperty("Partselect", "choices parameter value 2", get("Machselect"));
applyProperty("Partselect", "field type", "select box");
Part drop down
Choice selection : digits(dept) = ? and digits(mach) = ?
Choice parameter value: script:get("Deptselect");
Chioce parameter value 2: script:get("Machselect");
I am enclosing the way I have been coding this.
OnChange event for Department drop-down
applyProperty("Partselect", "choices parameter value", get("Deptselect"));
applyProperty("Partselect", "field type", "select box");
OnChange even for Machine drop-down
applyProperty("Partselect", "choices parameter value 2", get("Machselect"));
applyProperty("Partselect", "field type", "select box");
Part drop down
Choice selection : digits(dept) = ? and digits(mach) = ?
Choice parameter value: script:get("Deptselect");
Chioce parameter value 2: script:get("Machselect");
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: multiple parms with script:
Patti, you may need both... but they serve different purposes. The "script:" part runs when the display is loaded (i.e. when the RPG does EXFMT or READ or whatever it's doing) the applyProperty, however runs when someone makes a change to the Department or Machine dropdowns. Hopefully that makes sense.
If a p2 is not bieng submitted, there are two possible reasons:
1) Because the value is blank
2) Because the applyProperty() is not working.
I got the impression from your earlier messages that it's the code that runs under the "script:" properties that is the one that's not working, and since that doesn't use applyProperty(), I'm thinking that the get() is returning a blank value, and I showed you that alert() trick to help you troubleshoot it.
In the event that it's the applyProperty that isn't working, then the pui.properties["choices paramter value 2"] = XXX insteaed of applyProperty() might solve the problem.
Make sense?
If a p2 is not bieng submitted, there are two possible reasons:
1) Because the value is blank
2) Because the applyProperty() is not working.
I got the impression from your earlier messages that it's the code that runs under the "script:" properties that is the one that's not working, and since that doesn't use applyProperty(), I'm thinking that the get() is returning a blank value, and I showed you that alert() trick to help you troubleshoot it.
In the event that it's the applyProperty that isn't working, then the pui.properties["choices paramter value 2"] = XXX insteaed of applyProperty() might solve the problem.
Make sense?
-
- Experienced User
- Posts: 147
- Joined: Tue Jun 17, 2014 4:00 pm
- First Name: Patti
- Last Name: Bednarz
- Company Name: McGard
- State / Province: New York
- Country: United States
- Contact:
Re: multiple parms with script:
Scott,
I have spent the better part of the morning trying different things and documenting my results. I am enclosing my data. It still seems to boil down to the use of the "script:get" for multiple parameters. At one point I actually got a value for parameter 2, but BOTH parameters ended up having the value for machine? I think the second applyProperty("Partselect", "field type", "select box"); maybe overwrites the first? At any rate, nothing seems to work. Could we possible follow-up with a phone call? Patti
I have spent the better part of the morning trying different things and documenting my results. I am enclosing my data. It still seems to boil down to the use of the "script:get" for multiple parameters. At one point I actually got a value for parameter 2, but BOTH parameters ended up having the value for machine? I think the second applyProperty("Partselect", "field type", "select box"); maybe overwrites the first? At any rate, nothing seems to work. Could we possible follow-up with a phone call? Patti
- Attachments
-
- debugsample.docx
- (290.07 KiB) Downloaded 90 times
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: multiple parms with script:
I don't understand why you're applying the field type twice? Applying field type will cause it to re-render the widget, which involves drawing the select box on the screen, running the SQL statement, and putting the output of the SQL statement into the choices.
The way you're doing it, you're setting one parameter, then running the SQL statement with just that parameter set. Then you're setting the other one, and running the statment a second time.
I suspect you really want to set both parameter markers first, and then apply the field type.
I don't understand why you are setting "choices parameter value 2" to "Machselect". Shouldn't it be set to get("Machselect")?
The way you're doing it, you're setting one parameter, then running the SQL statement with just that parameter set. Then you're setting the other one, and running the statment a second time.
I suspect you really want to set both parameter markers first, and then apply the field type.
I don't understand why you are setting "choices parameter value 2" to "Machselect". Shouldn't it be set to get("Machselect")?
Who is online
Users browsing this forum: Bing [Bot] and 2 guests