Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

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

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());

}