Variables shown in approval form

emanuelesignori
Kilo Contributor

Hi,

I don't understand what kind of variables are shown on the Approval Form, because i've noticed that not all variables are shown.

I would like to know how to show only variables that are visible in Catalog Item view, is this possibile? How can i do this?

 

Thanks in advance.

1 ACCEPTED SOLUTION

Hi Emanuele,



You will need to investigate the Approval Record widget. You can see this line there:



if (itemsGR)


    item.variables = $sp.getRecordVariablesArray(itemsGR);



Which then is used in the body to display those:


<div ng-repeat="variable in item.variables" class="m-b-xs" ng-if="variable_toggle">


    <label>{{::variable.label}}</label>


    <div>{{::variable.display_value}}</div>


</div>



Unfortunately I can't see any docs about getRecordVariablesArray and how it gathers those variables:


documentation/widget_server_script_apis.md at b7caf92ec819c9ea2e1815200f75bf57ee9de47b · service-po...




Regards



Greg


View solution in original post

6 REPLIES 6

shloke04
Kilo Patron

Hi,



Can you elaborate more on your issue? Screenshot provided would be more helpful in debugging.



Regards,


Shloke


Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hi Shloke,


my issue is on the approval form on the Service Portal, this is an example:



find_real_file.png



Under the Options are shown some variables that i've defined in the request.


I don't understand what kind of variables are displayed: in this example the first 4 variables are displayed in catalog item view, but the last 2 are hidden on the service portal and there are other variables that i've defined which are not visible... why? How can i select the variables to show?



Thanks!


Hi Emanuele,



You will need to investigate the Approval Record widget. You can see this line there:



if (itemsGR)


    item.variables = $sp.getRecordVariablesArray(itemsGR);



Which then is used in the body to display those:


<div ng-repeat="variable in item.variables" class="m-b-xs" ng-if="variable_toggle">


    <label>{{::variable.label}}</label>


    <div>{{::variable.display_value}}</div>


</div>



Unfortunately I can't see any docs about getRecordVariablesArray and how it gathers those variables:


documentation/widget_server_script_apis.md at b7caf92ec819c9ea2e1815200f75bf57ee9de47b · service-po...




Regards



Greg


dianemiro
Kilo Sage

Hi Emanuele,



I was able to get this requirement by:



Step 1: creating an Email Script:



template.print("<b>Summary of Requested items:</b>\n\n");  


  var item = new GlideRecord("sc_req_item");


  item.addQuery("sys_id", current.sysapproval);


  item.query();


  while(item.next()) {


    //     template.print("       Options:\n");


          var keys = new Array();


          var set = new GlideappVariablePoolQuestionSet();      


          set.setRequestID(item.sys_id);


          set.load();


          var vs = set.getFlatQuestions();


    template.space(4);


    template.print('         ' + 'Requested by: ' + item.request.requested_for.getDisplayValue() + "\n");


          for (var i=0; i < vs.size(); i++) {


    if(vs.get(i).getLabel() != '' && vs.get(i).getDisplayValue() != '' && vs.get(i).getDisplayValue() != 'false') {


                    template.space(4);


    template.print('         ' +   vs.get(i).getLabel() + ": " + vs.get(i).getDisplayValue() + "\n");


              }


          }


  }


find_real_file.png


Step 2: And then using this script on your template, for example:



Dear ${requested_for},



please review the SAP user request. Below you will find links to approve or reject it.


Please see details below:


${mail_script:sysapproval_approver_script_sap_user}//this is the notification script created in Step 1.



---


Kind regards,
your IT Service Desk



Step 3: You will be able to use this template for your Approval Inserted Notifications.



The email script will display all variables except for those null variables.



Let me know if this helps.