Cart API / Service Catalog Script API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2014 01:30 PM
Hello,
I'm pretty new to the SN world, and I have an issue I want to see if you guys can help me with.
I created the Inbound Email Action (shown below) for our On-Boarding process, but
1) Sometimes it works, sometimes it doesn't (giving only the following info: "Skipping 'Create OnBoarding Request', did not create or update sc_req_item"). I haven't been able to pin point how, when, or why...
2) When it does work, it doesn't populate any of the variables (values hard-coded for now), or at least they don't show in the item created.
Any help would be really appreciated.
Thank you.
=======================================================
Target Table: Requested Item [sc_req_item]
=======================================================
gs.include('Cart');
createRequest();
function createRequest() {
var cart = new Cart();
// add in cart, substitute your cat item sys_id
var item = cart.addItem('ec2f659a6fa29100bbc6dd1cbb3ee4f6'); // On-boarding
//var item = cart.addItem('ea77984a6f629100bbc6dd1cbb3ee452'); // Configuration Auths for testing purposes
// set requested for, substitute your requested for
//Set Variables in your Cart Item
// REQUESTOR INFORMATION
cart.setVariable(item, 'type', 'New Employee');
cart.setVariable(item, 'title', 'Any Title');
cart.setVariable(item, 'email', 'Abel.Angulo@avmed.org');
cart.setVariable(item, 'department', 'IS');
cart.setVariable(item, 'phone', '305-671-0226');
//gs.addInfoMessage("Requestor finish");
//EMPLOYEE INFORMATION
cart.setVariable(item, 'full_name', 'Pepito Perez'); //email.body.name);
cart.setVariable(item, 'emp_title', 'Empl Title'); //email.body.title);
cart.setVariable(item, 'emp_department', 'IS'); //email.body.department);
cart.setVariable(item, 'emp_location', 'Miami'); //email.body.location);
cart.setVariable(item, 'eff_date', '2014-05-01'); //email.body.start_date);
//gs.addInfoMessage("Employee finish");
//HARDWARE REQUIREMENTS
cart.setVariable(item, 'service_desk_system', 'Desktop');
var cartmsg = "Received from: " + email.origemail + "\n\n" + email.body_text;
cart.setVariable(item, 'description', cartmsg);
var rc = cart.placeOrder();
//gs.addInfoMessage(rc.number);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2020 12:36 PM
Sorry to zombie thread this but had a question.
Have recently been working with inbound actions and came upon this post which was super helpful.
Am on New York release and I have used the recommended code:
var rc = adcart.placeOrder();
if (current.get('sys_id', rc.sys_id)) {
//insert any fields that need updating here
//current.work_notes = 'This is a test';
gs.log('Onboard email processing finish for ' + email.body.lastname + ', ' + email.body.firstname + ' ' + current.number);
current.update();
Working great but as noted, the result is that two REQ numbers get used with the latter assigned to the actual record produced and the former lost in space.
When turning on the system property: Assign a task number only upon insert, this issue is resolved and only one number gets used but noted a consequence of this in that when open a New Incident, the number field doesn't populate until save/update performed. This creates an issue with the way my helpdesk operates.
Overall, believe I'll just have to live with two REQ numbers getting used. Curious if anyone had any further comments/experience to do otherwise. As best I can tell, the loss of the unused REQ number is merely an annoyance.
Regardless, thanks all for posting, this was very helpful in getting me where I needed to be.
Thanks,
Andrew

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-27-2020 04:59 AM
We haven't had any issues using the setting that doesn't generate a Number until the record is saved. Our Service Desk uses the Call module when they first take a call which will insert a new Incident record with the relevant details from the Call record if they determine the call is actually an Incident (versus a training issue or status update or something else). That's worked really well for us.