Onload Catalog Client script top.windows.location infinity loop

Edxavier Robert
Mega Sage

Hi all, 

I am currently working on a catalog client script to re-direct user to a specific page after they click on a catalog item. I was able to do it by using an Onload catalog client script but after it re-directs gets into an infinity loops. 

function onLoad() {
   //Type appropriate comment here, and begin script below
   top.window.location = "sp?id=sc_cat_item_new_page&sys_id=109cdff8c6112276003b17991a09ad65";
}

How I can prevent the infinity loop?

1 ACCEPTED SOLUTION

Edxavier Robert
Mega Sage

Here is how I got it worked. 

1. Create a new service portal page, added my custom widget

2. Duplicate the catalog item

3. Hide the original catalog item from the portal

4. On the new catalog item added the catalog client script pointing to the original catalog item on the new page.

Tested out and working fine, when the user click on the new catalog item it re-direct very quick to the correct one. User will see like a flash less than a second the new one but is very fast. I didn't added any variables to the new one as it always will re-direct the user to the correct catalog item. 

 

An additional thing that I had to do on the new page was to add new Dynamic page title variable to get the catalog item name on the title tab. 

 

Thanks @SanjivMeher and @Jim Coyne for all your suggestions. 

View solution in original post

17 REPLIES 17

SanjivMeher
Kilo Patron
Kilo Patron

You can check if it is that page before redirecting the user. Ex

function onLoad() {
   //Type appropriate comment here, and begin script below
   if (top.window.location!="sp?id=sc_cat_item_new_page&sys_id=109cdff8c6112276003b17991a09ad65")
              top.window.location = "sp?id=sc_cat_item_new_page&sys_id=109cdff8c6112276003b17991a09ad65";
}

 


Please mark this response as correct or helpful if it assisted you with your question.

Hi, still the same infinity loop.

I also added an else condition with a return, but same results. 

From which page are you redirecting to the new one?

 

You can try this 

function onLoad() {
   //Type appropriate comment here, and begin script below
   var oldloc = "sp?id=sc_cat_item_new_page&sys_id=109cdff8c6112276003b17991a09ad65"
   if (oldloc.indexOf('sp?id=sc_cat_item_new_page')==-1)
              top.window.location = "sp?id=sc_cat_item_new_page&sys_id=109cdff8c6112276003b17991a09ad65";
}

Please mark this response as correct or helpful if it assisted you with your question.

Hi Sanjiv, I am trying to re-direct form the sc_cat_item page to a new page that I created which is sc_cat_item_new_page.