Record Producer - UI Confusion

themadhankumar
Tera Contributor

 

Record Producer redirects to form — record created only after clicking Update?

 

Question:

Hi everyone,

I’m working with a Record Producer in ServiceNow to create records in a custom "Leave Request" table.

Here is what I am observing:

  1. When I submit the Record Producer, it appears to save successfully.

  2. After submission, it redirects me to the form view of the record.

  3. On this form, I see an Update button instead of a Submit button.

  4. It seems like the record is only actually added to the table after I click the Update button.

My expectation was that the record should be inserted immediately upon submission of the Record Producer.

Is this expected behavior, or am I missing something in my configuration (such as script logic, setAbortAction, or redirect settings)?

Any clarification would be appreciated.

Thanks in advance!


👇 My Record Producer

themadhankumar_0-1777392555901.png

👇 Its Redirection

themadhankumar_1-1777392638115.png

 



1 ACCEPTED SOLUTION

@themadhankumar 

this happens all the time or sometimes

happens with admins or non-admins?

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

View solution in original post

5 REPLIES 5

vaishali231
Kilo Sage

hey @themadhankumar 

 Please share your Record Producer script.

Ankur Bawiskar
Tera Patron

@themadhankumar 

as soon as record producer is submitted the record should get created

any script is stopping it?

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

themadhankumar
Tera Contributor
The Below one is the script for mapping the values from the record producer to the table:
current.u_employee = gs.getUserID();

var leaveBalance = new GlideRecord('u_leave_balance');
leaveBalance.addQuery('u_employee', gs.getUserID());
leaveBalance.query();

if (leaveBalance.next()) {

    var totalLeaves = leaveBalance.u_used_leaves;
    var usedLeaves = leaveBalance.u_used_leaves;
    var remainingLeaves = totalLeaves - usedLeaves;

    var fromDate = new GlideDateTime(producer.u_from_date);
    var toDate = new GlideDateTime(producer.u_to_date);

    var diff = gs.dateDiff(fromDate.getDisplayValue(), toDate.getDisplayValue(), true);
    var days = Math.ceil(diff / (24 * 60 * 60)) + 1;

    if (remainingLeaves >= days) {

        current.u_number_of_days = days;
        current.u_status = 'Pending';

    } else {

        current.u_number_of_days = 0;
        current.u_status = 'Rejected';
        gs.addErrorMessage("Not enough leave balance");
    }

} else {

    current.u_number_of_days = 0;
    current.u_status = 'Rejected';
    gs.addErrorMessage("Leave balance record not found");
}

and I have done the following in sequence and I have documented along side

@themadhankumar 

this happens all the time or sometimes

happens with admins or non-admins?

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