
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2019 08:57 AM
I am looking to create a record producer that updates an existing record on a table rather than inserting a new entry.
This is to enable a non ITIL user to submit an update on a table that I created for the team.
The record producer contains one reference variable.
Once a selection is chosen, I have a script that populates 4 single line variables with the relevant information from the table.
These variables are editable and a user can update what is pre-populated.
They also add text (reason) which I want to add to a journal field on the record.
So far, I have only managed to get it to insert a new record - I guess thats why its called a record producer!
Is there any script that I can user in order to update the record based on the details on the record.
The reason for wanting to do as a producer over a RITM with workflow is that I also want to give them the option to create a new record down the line.
MAny thanks for any help you can provide
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-06-2019 04:06 AM
I have now completed this requirement by using the following script:
var record = producer.u_job_category;
var review = new GlideRecord('u_agency_rate_a');
review.addQuery('sys_id', record);
review.query();
//if we find a record update it
if (review.next()) {
review.u_agency_charge_rate_a = producer.rate_a;
review.u_agency_charge_rate = producer.rate_b;
review.u_average_rate_a = producer.rate_a_weekly;
review.u_average_rate_b = producer.rate_b_weekly;
review.u_agency_journal = producer.journal;
review.update();
gs.addInfoMessage("The record has now been updated");
current.setAbortAction(true);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2019 09:05 AM
Hi,
What you can do is query target record, update record, use then redirect to updated record or else it would be redirecting it to your new record. This you can try and check once
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2019 09:20 AM
Hi Matt,
I don't have a straightforward solution, but can share my experience in this area as I was trying to do something similar recently.
Initially, I wanted to use a record producer to make updates to an existing task but never got it working; instead, I created a second record producer accessed by clicking a custom button widget on the ticket portal page called "Edit Request". The widget pre-populated all variables on my second record producer with the values that were submitted in the original request. Upon submission, I setup a business rule that would cancel the original task in favor of the new task which contained the proper variables. While this approach worked from a technical perspective, we didn't like creating new records every time users wanted to make updates.
I ended up utilizing (and would recommend) the OOTB Form widget instead. You can configure views and ACLs on your custom table to give users access to create and edit fields directly from the portal.
Hopefully you find a solution that works best for you!
Thanks,
-Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2021 12:54 PM
Hello,
I used the OOB Form widget to show the information on the portal. How would I add a button for an end user so that they can submit the form after providing all the necessary information.
This is how its configured:
1. Created a page
2. In the page, there is Simple List widget points to a table and filtered to show only what they are assigned to.
3. When the user clicks the "view" next to the record in the list, the record is shown.
4. User only has the option to save. I want to create a button where user can click request for approval and state changes.
Thank You,
Van
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2019 11:21 AM
In your script on the record producer you can use the following to prevent the creation of a new record:
current.setAbortAction(true);