Current Ticket Number in Record Producer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2020 07:23 AM
Good morning developers,
I'm sure there is an easy answer to this question but I have not been successful in figuring it out. My problem is that I'm building out a form using a record producer. I'm trying to capture the current ticket number that will be created once the user clicks submit and display it in info message. I am able to get the sys_id but I can't get the display value. I have used var req = current.sys_id.getDisplayValue(); but that's not working.
I've also tried using this:
var agr = new x_adosy_as.Agreement(current);
var req = agr.record.number;
Here's the info message:
gs.addInfoMessage("Your Agreement Has Been Sent for Signature!" + req);
Any help will be greatly appreciated!
Thanks,
chnarris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2020 08:23 AM
Hi,
So which is your target table?
Can you share the record producer script?
Regards
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
05-22-2020 08:43 AM
No problem. My target table is x_adosy_as_agreement. I'm using the Adobe Sign Integration and on the merge data section of my script, all of the information is being sent to a form in Adobe, which is working but I can't get the ticket number to show for some reason.
Here is my script:
(function() {
//-----------------
// Read variables
//-----------------
// Collect the information that we need from the variables filled in by the user
var our_name = 'Tarrant County (TC) Information Technology Department (ITD) Requisition Request';
var preparer = producer.getDisplayValue('prepared_by');
var to_date = producer.date.getDisplayValue() + '';
var po = producer.purchase_requisition_number.getDisplayValue() + '';
var agr = new x_adosy_as.Agreement(current);
var req = agr.number;
var prev_po = producer.previous_po_number.getDisplayValue() + '';
var vendor_name = producer.recommended_vendor_name.getDisplayValue() + '';
var address = producer.vendor_address.getDisplayValue() + '';
var contact = producer.vendor_contact.getDisplayValue() + '';
var vendor_phone = producer.contact_number.getDisplayValue() + '';
var vendor_email = producer.email.getDisplayValue() + '';
var fund_center_1 = producer.fc1.getDisplayValue() + '';
var fund_center_2 = producer.fc2.getDisplayValue() + '';
var fund_center_3 = producer.fc3.getDisplayValue() + '';
var cost_center_1 = producer.cc1.getDisplayValue() + '';
var cost_center_2 = producer.cc2.getDisplayValue() + '';
var cost_center_3 = producer.cc3.getDisplayValue() + '';
var commitment_item_1 = producer.ci_1.getDisplayValue() + '';
var commitment_item_2 = producer.ci_2.getDisplayValue() + '';
var commitment_item_3 = producer.ci_3.getDisplayValue() + '';
var project_line = producer.project_line.getDisplayValue() + '';
var requestor = producer.requestor.getDisplayValue() + '';
var requestor_phone = producer.requestor_phone.getDisplayValue() + '';
var quantity1 = producer.quantity_1.getDisplayValue() + '';
var unit_type_1 = producer.unit_1.getDisplayValue() + '';
var description_1 = producer.description_1.getDisplayValue() + '';
var justification = producer.justification.getDisplayValue() + '';
var manager = producer.itd_resource_manager.getDisplayValue() + '';
// var bus_manager = producer.itd_business_services_manager.getDisplayValue() + '';
//var manager_id = producer.manager + '';
//var manager_name = producer.manager.getDisplayValue() + '';
// Compose the information that we will send to Adobe Sign
// This must be an object in field/value format
// The field names MUST match those of the Document fields of the template
var merge_data = {
//Remove the last comma
PreparedBy : preparer,
TD : to_date,
PurchaseReqNum : po,
ReqTrackingNum : req,
PreviousPONum : prev_po,
ITDResourceMg : manager,
VendorName : vendor_name,
Contact : contact,
Address : address,
VendorPhone : vendor_phone,
Email : vendor_email,
FundCenter1 : fund_center_1,
FundCenter2 : fund_center_2,
FundCenter3 : fund_center_3,
CostCenter1 : cost_center_1,
CostCenter2 : cost_center_2,
CostCenter3 : cost_center_3,
CommitmentItem1 : commitment_item_1,
CommitmentItem2 : commitment_item_2,
CommitmentItem3 : commitment_item_3,
ProjectLine : project_line,
Requestor : requestor,
RequestorPhone : requestor_phone,
Quantity1 : quantity1,
UnitType1 : unit_type_1,
Description1 : description_1,
Justification : justification
};
//-------------------------
// Set Adobe Sign objects
//-------------------------
// Create an Agreement object to allow us to add the Document and Signers
var ag = new x_adosy_as.Agreement(current);
// Hardcoded sys_id of the Document template for this Catalog Item
var template_id = 'd95ffefedb3c5850918c2b35ca9619ca';
// Add a Source document to the agreement and pass in the data to prefill its fields
// (We can pass in either the sys_id of a template, or the sys_id of an attachment)
//
ag.addDocument(template_id,merge_data);
// Add the two signers
// (We can pass in either the sys_id of a user, or an email address as a string)
//
ag.addSigner(manager);
//ag.addSigner(bus_manager);
//---------------------
// Set Agreement info
//---------------------
// Set the name of the Agreement record from the supplied 'name' variable
current.name = our_name;
// Set the URL that users will be redirected to after signing
current.post_sign_uri = '/x_adosy_as_agreement.do?sys_id=' + current.sys_id + '&sysparm_view=x_adosy_as_end_user';
// Set the agreement to 'Ready' to tell it to submit to AdobeSign after it is saved
current.state = 'Ready';
})();
gs.addInfoMessage("Your Agreement Has Been Sent for Signature!" + current.number);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2020 08:23 AM
Nevermind, the message popped up but it did not have the ticket number in the message. It just showed, Your Agreement Has Been Sent for Signature!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2020 08:32 AM
Is this answered?
Kindly close the thread by marking Answer as ✅ Correct & 👍Helpful so that it does not appear in unanswered list.
Regards
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
05-22-2020 09:22 AM
Hi,
What Ankur suggested should have worked.. !!
Can you please check the back-end name of Number Field also try with getDisplayValue().
gs.addInfoMessage("Your Agreement Has Been Sent for Signature!" + current.number.getDisplayValue());
Kind Regards,
Mohammad Danish