How to make few fields read only in order guide which should not impact individual catalog items

Sindhu45
Kilo Contributor

Hi everyone,

I've an order guide which has 5 catalog items in it. On entering the details in first page while placing the order in service portal, the fields are cascading to the next page "choose options". Here I've to make the fields read only which were cascaded from previous page. This I've done and working as expected while requesting order guide.

But the problem is when I'm ordering the individual catalog items, the fields which I've made read only becoming read only and not able to select anything. Please help me on making it applicable only when ordered through order guide.

I've written the below script in every included catalog items UI Policy, to make it applicable only in order guide.

//execute if true

function onCondition() {
var item = g_form.getValue("sysparm_guide");
if(item == 'sys_id_of_order_guide'){
return true;
}

//execute if false

return false;

 

Please suggest me on this.

Thanks in advance!

 

Regards,

Sindhu

1 ACCEPTED SOLUTION

Suseela Peddise
Kilo Sage

Hi,

Easiest way is to create a variable set and create a 'Yes/No' variable in the set. Hide this field always on the  form. Include this variable set on the catalog items. Then create UI policy on the catalog items to make fields read-only on order guide. Use variable set variable to identify the item opened through order guide.

Use below onLoad client script on variable set to set the variable value. 

function onLoad() {
//Type appropriate comment here, and begin script below

//portal
try{
var isOrderGuide = g_service_catalog.isOrderGuide();

if (isOrderGuide) {
var urlString=top.location.toString();
if((urlString.indexOf('sc_cat_item_guide')>-1) && (urlString.indexOf('sys_id=0890bb30dbdef78069adba213996190e')>-1) )//check if it is part of order guide.Update the sys_id of the guide
g_form.setValue('orderGuide','Yes'); //replace with variable name

}
}
//Desktop code
catch(e) {
var guide=g_form.getParameter("sysparm_guide");
if(guide=='0890bb30dbdef78069adba213996190e')//check if it is part of order guide. Update the sys_id of the guide
g_form.setValue('orderGuide','Yes');//replace with variable name
}

}

 

Include the variable set on catalog items. Create a UI policy on those catalog items to make fields read-only.

Ex: UI policy

condition: orderGuide is Yes

UI policy action : select the field and set read-only true.

 

If I have answered your question, please mark my response as correct and/or helpful.

Thanks,

Suseela P.

View solution in original post

9 REPLIES 9

Hi Suseela,

 

I've added an else condition, then it worked for me. Thanks a lot for the quick response. It helped me very much.

 

Regards,

Sindhu Musunuri

Anil Shewale
Mega Guru

Hi Sindhu

Try this onload catalog client script (assuming this is on a variable set?).

var thisGuide = $("sysparm_guide").value;

var thisItem = $("current_item").value;

if(thisGuide == thisItem) {

g_form.setReadOnly('Myvariable', true);// write your variable name

}

This should make the variable read-only as the order guide loads (or if you navigate back to the Describe Needs screen) but would take no action when a catalog item is loaded (when you click choose options).

 

If it help mark helpful or correct 

Thanks and regards

Anil

not working script is throwing an error on portal 

SKum
Kilo Sage

Have you got this worked? tried the same but its not working for me 

Joe DeStefano2
Tera Expert

The solution marked correct works.  Make sure your Yes/No variable in the variable set has a default value of No