IT Process Automation

Expand all | Collapse all

PAM 4.3.1 - IRF - Insert an empty element into a Select result

Jump to Best Answer
  • 1.  PAM 4.3.1 - IRF - Insert an empty element into a Select result

    Posted 01-30-2017 04:11 PM

    I am using a Select dropdown to pull a list of groups from SDM onLoad of my IRF.  The query is working as expected and I am populating the list using the sample code from the Pre-Defined Content examples, under User Interaction forms, section 08 - Populate Dropdown DB onLoad.

     

    This is a required field.  However, it displays all the results and so it is possible for someone to actual skip this field because it will be pre-populated with the first element from the results.

     

     

     

     

     

    I need to have this list start with an empty/blank element so it can't be skipped.  I've looked at the ca_pam_addValuesInSelectStore but didn't see a method of 'unshift' into the list after it is filled from the query. 

     

     

    I have changed the DB query function from Form onLoad() to Form.NewHireGroup onClick.  This does start out blank on form load but onClick returns the first result into the field and the user must click it a second time to get the full dropdown list.

     

     

    Do I need to do a conversion of the 'Form.NewHireGroup' object and then run JavaScript array.unshift() against that and return it from callback?

     

    I have tried setting vars of emptyName and emptyValue and then tried to update the Form.NewHireGroup field after the select store is created using ca_pam_addValuesInSelectStore('Form.NewHireGroup',emptyName,emptyValue); but no effect.

     

    I've also looked at the Lookup functions but could use an example of using the SQL function for the 'get' and returning that to the 'set' one.

     

    I see this has been an issue before, I found these previous Questions marked 'Answered' but the OP didn't share the results.

     

    Issue with lookup field in an IRF 

    Click or Select Events on IRF Table?  

     

    TIA,

    J.W.



  • 2.  Re: PAM 4.3.1 - IRF - Insert an empty element into a Select result
    Best Answer

    Posted 02-02-2017 09:23 AM

    Hi J.W.,

     

    I got this to work by modifying the script of the IRF in the out-of-the-box process in the following way:

    populateFoodSQL : function() {
    var callBack = new Object();
    var blankName = [""];
    var blankValue = ["emptyV"];
    var newStore = ca_pam_createSelectStore(blankName ,blankValue )
    callBack.onSuccess = function(result)
    {

    ca_pam_clearSelectStore('Form.dropdown');
    ca_pam_addValuesInSelectStore('Form.dropdown',ca_pam_createSelectStoreFromSQLResult(result,'name'));
    ca_pam_addValuesInSelectStore('Form.dropdown',newStore);
    ca_pam_selectOption('Form.dropdown', '', 'emptyV', true);

    }

     

    So basically I created a blankName and blankValue variable and then added that to the dropdown values.  Then I used the ca_pam_selectOption to select that blank value.  I left the function running at the "OnLoad" level of the IRF.  

     

    Hope this helps.



  • 3.  Re: PAM 4.3.1 - IRF - Insert an empty element into a Select result

    Posted 02-02-2017 07:10 PM

    Thanks Andrew! 

     

    I thought (read:  "assumed") ca_pam_clearSelectStore() would have cleared that out; so I was looking for an unshift method.  I will let you know when I get a chance to put it in effect.

     

    J.W.



  • 4.  Re: PAM 4.3.1 - IRF - Insert an empty element into a Select result

    Posted 02-03-2017 05:25 PM

    Andrew,

     

    Works like a charm.  Going into the script file.

     

    Cheers and Happy Friday!

     

    J.W.