Service Portal Mandatory Fields

jamesk-apm
Kilo Contributor

Hi All,

We are running Helsinki patch 5 and have started to look at implementing the shopping cart in the Service Portal. The problem we are having is trying to make fields mandatory. See screenshot below showing the field we would like to make mandatory:

Service Portal Mandatory Field.png

We have client script code that is set to run for both mobile and desktop set for the UI type. This works in the Service Catalog but not in the Service Portal when attempting a checkout without a Business Justification set. I am assuming I need to set this in the client script of the widget in question, just not sure where to start with the code for this.

Does anyone have some links to good resources to help with developing widgets?

Thanks

James

1 ACCEPTED SOLUTION

mandle
Mega Guru

James,



I'd first like to caution you about leveraging the Helsinki Patch 5 shopping cart widgets. We're not sure why they were included since the Shopping Cart and Bundles in Service Portal are most likely not being released until Istanbul.



That said, it appears from your screenshot that you are trying to make the relabeld Special Instructions field, "Business Justification", field mandatory in the "SC Shopping Cart" widget.


The HTML for that field is in the sp_ng_template called "large_shopping_cart.html" record:


Since you've already taken ownership of the "large_shopping_cart.html" template record you could add in a "placeholder" value that also draws attention to the mandatory nature of this field.



You could add the following to the "Client Script" on the "SC Shopping Cart" widget


Between Lines 13-14 add the following:



if (c.additionalDetails == '') {


  1.         spUtil.addErrorMessage('Business Justification is required before Checkout. Thank you!');                                          
  2.         return;
    }                                  


And you could add some CSS to the "SC Shopping Cart" widget to draw attention to the mandatory "Business Justification":


I'm adding minimal CSS here but you could go further...



.special-instructions-details label {


  color: tomato;


}




Results:



Screen Shot 2016-11-15 at 11.49.21 AM.png



Screen Shot 2016-11-15 at 11.49.29 AM.png


View solution in original post

6 REPLIES 6

jamesk-apm
Kilo Contributor

Thanks all for your responses.



Brad, yes it appears I was using unsupported code in the client script.



Jeremy, that worked for me thanks very much.



James


SRJ
Tera Contributor

HI All,

Some one help me to write a script in the SC Shopping cart widget line manager can't be an approver(vice versa).Line manager is auto populating from user profile data and also user can manually change their line manager