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

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.

Hi Suseela,

 

Thank you for the reply. But I've tried the above solution, but it is still not working. I've created a 'yes/no' variable in the variable set and hidden it using UI Policy.

 

After that created an onLoad catalog client script in the variable set as given above.

 

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

//Here I've mentioned the order guide sys_id 


g_form.setValue('orderGuide','Yes'); //replace with variable name

//Here I've mentioned the Yes/no variable name created


}
//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

//Here I've mentioned the order guide sys_id 


g_form.setValue('orderGuide','Yes');//replace with variable name

//Here I've mentioned the Yes/no variable name created
}

}

 

Please let me know if you have any suggestions.

 

Regards,

Sindhu 

 

Also I've give the UI Type as "All" in the catalog client script. 

Have included the variable set on catalog items? Have you create UI policies on catalog items to make fields read-only?

1. Include the variable set on all catalog items included in order guide.

2. Create a UI policy on individual catalog items to make fields read-only.

Use condition as 

orderGuide is Yes

 

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

Thanks,

Suseela P.