Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Error

shaliniT
Giga Explorer

On submitting the Catalog form facing this kind of issue . And this is happening through this code. 

 var grrequest = new GlideRecord('sc_request');
    grrequest.get(current.request);
    //grrequest.addQuery('request', current.request);
    grrequest.requested_for = current.variables.open_for;
    grrequest.setWorkflow(false);
    grrequest.update();
error:
shaliniT_0-1710915087183.png

 

Can I get any solution to this?

 

1 REPLY 1

Community Alums
Not applicable

This typically happens when you're trying to set a value that violates a unique constraint defined on one or more fields in the record.

 

Kindly check if there are duplicate entries in the sc_request table that have the same value for the field(s) involved in the unique constraint.
var grDuplicate = new GlideRecord('sc_request');

grDuplicate.addQuery('requested_for', current.variables.open_for); // Assuming 'requested_for' is involved in the unique constraint

grDuplicate.query();

while (grDuplicate.next())

{

gs.info('Duplicate sc_request found: ' + grDuplicate.getUniqueValue());

}