I’m trying to use a popup form to, ultimately, set a value on the calling form. I am calling the popup modally but I found in webclient that code execution doesn’t stop when the showformindialog() is called (I was originally going to set a global in the popup and then set my field once the popup was dismissed).
So, another method was required. Since I want the popup to be called from several forms I was hoping to do the following…
on the calling form set a global variable to the field name of what I ultimately want populated
call the popup
user selects value and accepts
popup determines calling form (from getMethodTriggerFormName) and field (from global) and tries to set that to the selected value
popup closes
When I try this I get an error…
Can’t put in a locked scope, name: finance_id, value: 26502
java.lang.RuntimeException: Can’t put in a locked scope, name: finance_id, value: 26502
Here’s the code I’m trying on my popup…
finance_id is the field on the popup containing the code I need.
formname is the correct value
elementname is the correct value as globals.main_finance_id_field is set on my calling form
var formName = application.getMethodTriggerFormName();
var elementName = globals.main_finance_id_field;
application.output('formname is '+ formName);
application.output('elementname is '+ elementName);
forms[formName].elements[elementName] = finance_id;
application.closeFormDialog();
I’m sure my noob approach can be substituted with something alot more clever - any ideas ?
I am calling the popup modally but I found in webclient that code execution doesn’t stop when the showformindialog() is called (I was originally going to set a global in the popup and then set my field once the popup was dismissed).
That’s right a modal dialog cannot block a thread’s execution on the server.
The easiest way to do this in Web Client is to use an onHide() handler for the dialog form.
You can attach it back to a method in the calling form to continue the process.
Or if you need it to be more flexible, (used by many forms) you can pass in and store a function object to call as a call-back.
If you want to do that, below is a hypothetical code scenario
Hope this helps,
Sean
dialog form methods:
shows the dialog w/ an optional callback:
function showMe(){
var initialStuff = arguments[0];
callbackFunctionName = arguments[1];
application.showFormInDialog(this);
}
on hide handler to invoke callback:
function onHide(){
if(callBackFunctionName){
eval(callBackFunctionName + '(' +otherStuff+ ')')
}
Calling Form methods:
shows the dialog form:
function showDialog(){
forms.dialogForm.showMe(initialStuff, 'dialogCallBack');
}
handles the callback:
function dialogCallBack(){
var modifiedStuff = arguments[0];
// go to town
}
I tried what you suggested and it is pretty cool - all the mechanics work exactly as they should (w00t!!)
BUT… I have a problem… the return value is fine when I dump it out via application.output but the value that displays in the field that is updated on my calling form is not “formatted” correctly…
For example, according to my application.output the value that ‘comes back’ is “26501” (this is an id/foreign key value which is exactly what it should be) but the value that gets populated in the field of interest is “26501.0” - where is this extra .0 coming from ?? The field comes from a column in a table that is a varchar2(20).
There is no defined format on the field on the calling form.