Ui Action order guide level.

LaraReddy
Tera Guru

Hi All,
Can anyone please help us on the below issue.

We have created one UI action and UI page to redirect the catalog items and order guides to service portal and it's working fine for catalog items.
But when it comes to Order guides also it's re directing as normal catalog item on portal level

Ui Action:
Name: Try in Portal
Table: Catalog item (sc_cat_item)

onClick: openPortalPageList()
condition: current.active == true
Script: 

function openPortalPageList() {
    var itemID = g_form.getUniqueValue();
    var gdwPortals = new GlideDialogWindow('try_item_portal_page');
   
    gdwPortals.setTitle('Try Portal Page (select portal)');
    gdwPortals.setPreference('portal_page_id', 'sc_cat_item');
    gdwPortals.setPreference('item_id', itemID);
   
    gdwPortals.render();
}

UI Page:
Name: 
try_item_portal_page
HTML:


<j:set var="jvar_page_id" value="${RP.getWindowProperties().get('portal_page_id')}"/>
<j:set var="jvar_item_id" value="${RP.getWindowProperties().get('item_id')}"/>
<g:evaluate var="jvar_gr" object="true" jelly="true">
    // find existing portals
    var grPortal = new GlideRecord("sp_portal");
    grPortal.addEncodedQuery('sys_scope=global');
    grPortal.query();
    grPortal;
</g:evaluate>

<j:while test="${grPortal.next()}">
    <div style="padding:4px;" onclick="goThere('${grPortal.url_suffix}', '${jvar_page_id}', '${jvar_item_id}')">${grPortal.title} (/${grPortal.url_suffix})</div>
</j:while>
 
Client script:

function goThere(suffix, id, item) {
    var url = new GlideURL('/' + suffix);
    url.addParam('id', id);
    url.addParam('sys_id', item);
    var w = getTopWindow();
    GlideDialogWindow.get().destroy();
    w.popupOpenFocus(url.getURL(), 'try_portal_page', 950, 700, '', false, false);
}


Advance thanks.
1 ACCEPTED SOLUTION

Kartik Magadum
Kilo Sage

Hello @LaraReddy 

It seems like there might be an issue in how the order guides are being handled in the redirection process. Let's take a closer look at your UI action script.

function openPortalPageList() {
    var itemID = g_form.getUniqueValue();
    var gdwPortals = new GlideDialogWindow('try_item_portal_page');
   
    gdwPortals.setTitle('Try Portal Page (select portal)');
    gdwPortals.setPreference('portal_page_id', 'sc_cat_item');
    gdwPortals.setPreference('item_id', itemID);
   
    gdwPortals.render();
}

It looks like you are setting the 'portal_page_id' preference to 'sc_cat_item', which might be causing the redirection to treat it as a catalog item. You need to dynamically determine whether the current item is a catalog item or an order guide and pass that information to the UI page.

You can modify your UI action script like this:

function openPortalPageList() {
    var itemID = g_form.getUniqueValue();
    var itemType = g_form.getValue('type'); // Assuming 'type' is a field that distinguishes between catalog items and order guides
    var gdwPortals = new GlideDialogWindow('try_item_portal_page');
   
    gdwPortals.setTitle('Try Portal Page (select portal)');
    gdwPortals.setPreference('portal_page_id', itemType);
    gdwPortals.setPreference('item_id', itemID);
   
    gdwPortals.render();
}

This modification assumes that there is a field named 'type' on the form that holds the information about whether the item is a catalog item or an order guide. Adjust the field name based on your data model.

Make sure to check how the 'type' field is populated for order guides, and update the script accordingly. This way, you can pass the correct information to the UI page and handle the redirection accordingly.

 

Please Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.

 

Thanks & Regards,

Kartik Magadum

View solution in original post

1 REPLY 1

Kartik Magadum
Kilo Sage

Hello @LaraReddy 

It seems like there might be an issue in how the order guides are being handled in the redirection process. Let's take a closer look at your UI action script.

function openPortalPageList() {
    var itemID = g_form.getUniqueValue();
    var gdwPortals = new GlideDialogWindow('try_item_portal_page');
   
    gdwPortals.setTitle('Try Portal Page (select portal)');
    gdwPortals.setPreference('portal_page_id', 'sc_cat_item');
    gdwPortals.setPreference('item_id', itemID);
   
    gdwPortals.render();
}

It looks like you are setting the 'portal_page_id' preference to 'sc_cat_item', which might be causing the redirection to treat it as a catalog item. You need to dynamically determine whether the current item is a catalog item or an order guide and pass that information to the UI page.

You can modify your UI action script like this:

function openPortalPageList() {
    var itemID = g_form.getUniqueValue();
    var itemType = g_form.getValue('type'); // Assuming 'type' is a field that distinguishes between catalog items and order guides
    var gdwPortals = new GlideDialogWindow('try_item_portal_page');
   
    gdwPortals.setTitle('Try Portal Page (select portal)');
    gdwPortals.setPreference('portal_page_id', itemType);
    gdwPortals.setPreference('item_id', itemID);
   
    gdwPortals.render();
}

This modification assumes that there is a field named 'type' on the form that holds the information about whether the item is a catalog item or an order guide. Adjust the field name based on your data model.

Make sure to check how the 'type' field is populated for order guides, and update the script accordingly. This way, you can pass the correct information to the UI page and handle the redirection accordingly.

 

Please Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.

 

Thanks & Regards,

Kartik Magadum