Submit the record producer from script

Royal1
Tera Contributor

i want to submit the record producer from the Business rule/transform map script .

 

is it possible to submit? 

4 REPLIES 4

Tony Chatfield1
Kilo Patron

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?

POC Instance
Tera Contributor

Hi Royal1, you can try using CART API methods to create new request from scripts, here you can find the attached document for the same below

Amit Gujarathi
Giga Sage
Giga Sage

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



Kiran_T
Giga Guru

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

Regards,
Kiran