User Criteria

Marcelo Pedrey1
Tera Contributor

Hello,

 

Brief background: We support multiple companies within a single SNOW instance, and most of the companies have their individual catalog items. For that, we utilize "User Criteria".  We also have an L1 desk that handles all of the companies, and this group has access to all of the catalog items in our instance regardless of the company.  We are having issues when they open a request for Company A for Computer A that is only available for Company B.  Is there a way to restrict the creation of a request using the "requested for" user's company name to prohibit that request from being submitted?

 

Thanks in advance

5 REPLIES 5

SAI VENKATESH
Tera Sage
Tera Sage

Hi You can try the below code 

On before business rule with insert/update

(function executeRule(current) {
    // requested item (e.g., Computer A) and its  company
    var requestedItemCompany = current.cat_item.company.getDisplayValue();

    // associated with the requested for user
    var requestedForUserCompany = current.requested_for.company.getDisplayValue();

 
    if (requestedItemCompany !== requestedForUserCompany) {
        gs.addErrorMessage('You are not authorized to request this item.');
        current.setAbortAction(true); // Abort the submission
    }
})(current);

 

Thanks and Regards

Sai Venkatesh

 

 

Marcelo Pedrey1
Tera Contributor

Thank you, Sai. Apologies for the delayed response.

 

This works. The only issue is that our support desk usually raises requests (catalog items) via Workspaces from an interaction. The message does pop up and does not allow the requested item to go through, but it does show that the request was submitted even though the request was not created. See attached 

 

MarceloPedrey1_0-1715344713264.png

 

Hi @Marcelo Pedrey1 

 

Can you close the question by marking as solution so that It will be helpful for others in the community

 

 

Thanks and Regards

Sai Venkatesh

AshishKM
Kilo Patron
Kilo Patron

Hi @Marcelo Pedrey1 , 

Seems like you have to review the current implementation logic and update the catalog item for company check logic.

Writing the BR which work on backend to stop such record creation not a good solution becuase the portal message  and actual work will be in mismatch condition. 

 

Additionaly, the L1 team need some training on such senario to avoid such cases.

 

-Thanks,
AshishKM


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution