Submit the record producer from script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2023 01:31 AM
i want to submit the record producer from the Business rule/transform map script .
is it possible to submit?
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2023 01:42 AM
Hi, unfortunately your question\requirement is not clear. A record producers enable end users to create a record by populating specific variables\fields in a UI form and these variables are then converted to target table field values when the form is submitted. If you are using a BR or transform to create data records then there is no reason to have a record producer involved. Perhaps you can clarify your business requirements\use case?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2023 01:48 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2023 02:19 AM
Hi @Royal1 ,
I trust you are doing great.
You can try the same using cart API.
// Create a new cart object
var cart = new sn_sc.Cart();
// Create a new record producer item in the cart
var producer = cart.addItem("a1b2c3d4e5f6", 1, "sc_cat_item_producer");
// Set the producer's requested for user
producer.requested_for = gs.getUserID();
// Submit the cart
var cartId = cart.submit();
// Check if the cart submission was successful
if (cartId) {
gs.info("Record producer submitted successfully");
} else {
gs.error("Failed to submit record producer");
}
Source link: https://docs.servicenow.com/bundle/paris-application-development/page/script/server-scripting/refere...
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2023 02:32 AM
Hi ,
You can try using the script below:
var rp=new GlideRecord('sc_cat_item_category');
if(rp.get('sc_cat_item.name','Name of the Record producer')){
var item= rp.sc_cat_item;
var url = 'com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=';
gs.getSession().putClientData('value1', current.name);// Pass data from your fields
Refer the https://developer.servicenow.com/dev.do#!/reference/api/tokyo/server/c_GlideSessionScopedAPI for information on glide session.
action.setRedirectURL(url);
Record Producer client script
function onLoad() {
g_form.setValue('name',g_user.getClientData('value1'));
saveProducer('');
}
Mark as helpful if it resolves your issue.
Regards
Kiran
Kiran