g_service_catalog.isOrderGuide doesn't work anymore

S_bastien SCHNE
Kilo Contributor

Hi everyone,

I am working on serveral Catalog Items and in one variable set I need to know if I'm in an order guide or standalone item.

I used the following code to determine that on Service Portal:

 

if (g_service_catalog.isOrderGuide)

{  // Do stuff if is in an order guide }

 

It returns always true. I checked using g_service_catalog.isOrderGuide(), since many examples I found used this code, but that one always returns false, wheither I'm in order guide or not.

 

I found that g_service_catalog.isOrderGuide returns the following sequence: 

function(){ return formModel.isOrderGuideItem ? true : false; }

 

Shouldn't that be "resolved" and simply return true or false ?

 

Thanks in advance for anyone that could help me.

 

7 REPLIES 7

sachin_namjoshi
Kilo Patron
Kilo Patron

g_service_catalog is only available in Service Portal service catalog item scripts. Use this API to know if your catalog item script is run as part of an order guide or on its own.

 

function onLoad() {
  if (window) // if CMS, don't run this
   return;

   // g_service_catalog api for Service Portal and Mobile
   var isOrderGuide = g_service_catalog.isOrderGuide();
   g_form.setValue("is_order_guide", isOrderGuide ? "Yes!" : "Nope :(");
}


Regards,
Sachin

Thanks for your answer, this in a common example I found, but...

g_service_catalog.isOrderGuide()

... always returns false, wheither I'm in an Order Guide or not.

S_bastien SCHNE
Kilo Contributor

// If it's in a order guide
if (g_service_catalog.isOrderGuide)
{

     // Do stuff

}

 

That works fine on our production instance.

 Add the following line of code to an onLoad catalog client script on both your Order Guide and an actual Catalog Item:

 

 

 

g_form.addInfoMessage("sysparm_guide = " + $("sysparm_guide").value + "<br/>" + "current_item = " + $("current_item").value + "<br/>" + "on the order guide itself = " + ($("sysparm_guide").value == $("current_item").value));

 

 

It will display the sys_ids of the Order Guide (sysparm_guide) and the Catalog Item (current_item).   You will be on the Order Guide's start page if both sys_ids are the same.

 

Regards,

Sachin