I want to filter "Request For" on Order confirmation pop up.

sai195
Tera Contributor

I want to restrict "Request For" on Order confirmation pop up to show users only based on logged-in user's organisation.

So i'm trying to call a script include in a system property "glide.sc.request_for.query" which returns a query.

But this is not working, could you please let me know how to call a script include in a system property or how can i restrict data.

I tried in the below ways to call script include in  a property as such "javascript:new <si_name>().<function>();" "new <si_name>().<function>();"

 

Thanks in Advance!!

1 ACCEPTED SOLUTION

sai195
Tera Contributor

Issue is resolved. I cloned the widget and added my script in script include.

i just commented and replaced this line of code in server script "data.reqForQuery = gs.getProperty("glide.sc.request_for.query");" with the below code

data.reqForQuery = check();
function check(){
var usrQuery ;
var usrOrg ;
gs.log('inside function1');
var loggedIn_user = gs.getUserID();
var uRec = new GlideRecord('sys_user');
uRec.addQuery('sys_id',loggedIn_user);
uRec.query();

if(uRec.next()){
usrOrg = uRec.getValue('company');
}
var gr = new GlideRecord('sys_user');
gr.addQuery('active',true);
gr.addQuery('company',usrOrg);
gr.query();
if(gr.next()){
usrQuery = gr.getEncodedQuery();

gs.log('Query returning : ' + usrQuery);

}
return usrQuery;

};

 

I have replaced the widget ID in portal

View solution in original post

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Sai,

that system property has a value which is of type string so it won't evaluate javascript code; just to explore. if I found anything will update

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Sai,

try this; use below UI macro updated code and try now; see the changes are highlighted in bold

it should try to show only those users who belong to same company as the logged in user's

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
    <j:set var="jvar_use_cart_layouts" value="${new SNC.ServiceCatalogLayoutService().useSCLayout()}" />
    <j:if test="${!jvar_use_cart_layouts}">
        <g:include_script src="CartCheckoutFunctions.jsdbx" />
    </j:if>
    <j:if test="${jvar_use_cart_layouts}">
        <g:include_script src="CartCheckoutFunctionsV2.jsdbx" />
    </j:if>

    <g:evaluate var="jvar_query">
        var query = 'companyIN' + gs.getUser().getCompanyID();
        query;
    </g:evaluate>    


    <div data-sn-macro-sys-id="${jvar_macro_sys_id}">
        <g:ui_reference table="sys_user" name="sc_cart.requested_for" value="${jvar_ref}"
                        displayvalue="${jvar_ref_display}" completer="AJAXTableCompleter" columns="${gs.getProperty('glide.sc.request_for.columns')}"
                        order_by="${gs.getProperty('glide.sc.request_for.order_by')}"
                        query="${jvar_query}"
                        onchange="catReqFor('sc_cart.requested_for');" />
    </div>
</j:jelly>

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Thanks for your reply.

It didn't work.

I can all see users.

Hi Sai,

Can you share the script here?

Regards

Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader