How to restrict product model records based on selection particular account in CSM portal in SNOW

Srinivasu2
Tera Contributor

Hi Community,

 

I have created new case form in CSM Portal and we have fields like Accounts and product (taken reference as Product model table)

 

we need to restrict Product based on selection of each particular account (means if we select one particular account it will show only that particular account products on Product field 

 

Srinivasu2_0-1710394225276.pngSrinivasu2_1-1710394584485.png

 

If we can restrict the field via script include and add here advanced reference qualifier, could you please share the script include code.

 

Thanks,

Srinivasu

 

 

6 REPLIES 6

M Ismail
Tera Guru

Hi @Srinivasu2,

You can create a reference Qualifer on Product variable here how you can do this 
Reference Qualifier code 

 

javascript:new sn_contributor.ContributorUserPortalUtils().getSoldProductRefQual(current.variables.account)

 

Script include code 

 

getSoldProductRefQual: function(account) {
    if (gs.nil(account))
        return;
    
    var gr = new GlideRecord("sn_install_base_sold_product");
    gr.addQuery('account', account);
    gr.query();
    
    var listOfSoldProducts = [];
    while (gr.next()) {
        if (gr.canRead())
            listOfSoldProducts.push(gr.sys_id + '');
    }
    
    return "sys_idIN" + listOfSoldProducts.join();
}

 

Please also check the screen shot below 

MIsmail_0-1710399150272.png

Please hit helpful and accept this as a solution if it solved your problem.
Thank you!

Hi @M Ismail ,

 

I have taken reference table as Product model(cmdb_model) instead of sold product table.

 

Could you please share script include code for Product model(cmdb_model)? it will be very helpful for this

 

Thanks,

Srinivasu

Hi @Srinivasu2,

What's the criteria like on what basis you want to show the cmdb_model like I can't see the account in cmdb_model table.

Hi @M Ismail ,

 

Client will be provided CMDB model table data we need to import and attach to account.

 

we can see product model in Account under related lists.

 

 

Srinivasu2_2-1710401372774.png

 

 

Thanks,

Srinvasu