I have a script emailing a custom PDF to an entity. The PDF is generated from a custom record, and I want to be able to see the email from the entity (ok - no problem), and also the custom record mail merge tab (or comms).
Entity is fine, but the custom record is not showing the email:
The code:
var records = new Object();
records['entity'] = venId[each];
records['customrecord_sow'] = sowId;
log('Attach email to records: '+stringify(records));
nlapiSendEmail(nlapiGetUser(), recipient, subject, body, null, null, records , newFile,true);
When I view the log, the record variable contains the following:
Attach email to records: { "entity": 11, "customrecord_sow": "264" }
The record internal id is correct, as the the custom record id. But the email does not show in the mail merge on the record.
What have I missed?
For custom records, you have to specify both the custom record type id as well as the custom record id in the records object. So in your case, you would need to do something like this:
records['recordtype'] = 'customrecord_sow';
records['record'] = sowId;
in place of records['customrecord_sow'] = sowId;
Related
Within Customization -> List, Records & Fields -> Custom Records I have a table with id: customrecord_{name} with the type "customrecordtype". I have multiple fields in that record
How can I use the load function to get all the data for this table/record? (For all the fields)
const data= record.load({
type: 'customrecord_{name}',
isDynamic: false
... //get all fields
});
I tried to look at the help center but am a bit lost on how to accomplish this.
As far as I know load won't do it. After loading a custom record with load, you can check all the fields of this custom record by calling data.getFields() method. This will return a list of field ids (including custom ones) that you can fetch by calling data.getValue such as data.getValue({'fieldId':'isinactive'}) // a regular field or data.getValue({'fieldId':'custrecord_routeproduce_highpriority'}) // a custom field
loading a custom record, checking its fields, fetching value of a custom field
guys!
I'm writing an email template for the invoices. On the invoice form I have a "Project" (internalId: Job) field -> on the "Project" form I have a "custom entity" field with employee-type. I can get an employee's name with ${transaction.job.custentity5}. But I can't get access to related fields such as email, phone number and etc. The code ${transaction.job.custentity5.email} gives me nothing. The code ${transaction.job.custentity5.mobilephone} gives me a strange error like "field job.mobilephone not found" (netsuite hides custentity5 in this objects chain), but I see this field in employee's profile.
How do i get child values from custentity field?
Unfortunately, you can't go into such a deep level with the standard data provided.
You can however fetch the data with a search.lookupFields during a beforeLoad and set it as default value on a custom field of the form.
/**
* #NApiVersion 2.x
* #NScriptType UserEventScript
*/
define(['N/ui/serverWidget', 'N/search'], function(serverWidget, search) {
function beforeLoad(context) {
var invoice = context.newRecord;
var form = context.form;
var type = context.type;
var UserEventType = context.UserEventType;
// only execute during printing...
if (type != UserEventType.PRINT) return
var jobID = invoice.getValue({fieldId: 'job'});
// return when no job/project is set on the invoice...
if (!jobID) return
var job = search.lookupFields({
type: search.Type.JOB,
id: jobID,
columns: ["custentity5"]
})
// return when no employee is set on the project...
if (!(job.custentity5 && job.custentity5[0] && job.custentity5[0].value)) return
var employee = search.lookupFields({
type: search.Type.JOB,
id: job.custentity5[0].value,
columns: ["email", "phone"]
})
var field = form.addField({
id : 'custpage_custom_data_employee',
label: 'Employee',
type : serverWidget.FieldType.LONGTEXT
});
field.defaultValue = JSON.stringify(employee);
}
return {
beforeLoad: beforeLoad
};
})
You can access the data within the template through:
<#if record.custpage_custom_data_employee?has_content>
<#assign employee = record.custpage_custom_data_employee?eval />
</#if>
Netsuite doesn't drill down that far for you. Generally you get one step away from the primary record so you see a name using ${transaction.job.custentity5} because you'd see a name if you opened the associated job record.
How you can show the details from custentity5 depends on a bunch of factors like who is sending this email? Is is special enough to have its own button? Is the email being sent batch etc.
Options:
A before load user event script can check whether the record is being printed or emailed the standard way. That script can load and populate custom fields on the main record so you may be able to reference ${transaction.custpage_ent5.mobilephone} where you'd added the job's custom entity to the transaction
fully script your email using n/Render. You'll likely need to script everything but you can look up and add arbitrary records and datastructures to your renderer. This would be triggered by a custom button or batched script.
I have a question regarding the following scenario.
I have a Docusign template with 2 documents. Template contains two Template Roles with few signature tags applied on documents. There could be also Text Input tags, checkbox tags etc...
What I need is to send an envelope with documents that will replace both template documents but to apply DocuSign tags (signature, checkbox..) that were configured in the template, to apply document visibility, and as much DS template features as it can.
Signature request (envelope) is sent using DocuSign.eSign C# client library.
I'm using following code that builds Composite Template that contains two new documents with appropriate documentIDs retrieved from DocuSign template.
EnvelopeDefinition envDef = new EnvelopeDefinition();
envDef.EmailSubject = "Subject";
envDef.EmailBlurb = "Body";
envDef.CompositeTemplates = new List<CompositeTemplate>();
envDef.CompositeTemplates.Add(new CompositeTemplate
{
ServerTemplates = new List<ServerTemplate> {
new ServerTemplate
{
Sequence = "2",
TemplateId = "TEMPLATE_ID_GOES_HERE"
}
},
InlineTemplates = new List<InlineTemplate>
{
new InlineTemplate
{
Sequence = "1",
Documents = new List<DocuSign.eSign.Model.Document>
{
new Document
{
DocumentBase64 = "...", //document content
Name ="some.pdf",
DocumentId = "TEMPLATE_DOC1_ID_GOES_HERE" //ID of template document that should be replaced
},
new Document
{
DocumentBase64 = "...", //document content
Name ="another.pdf",
DocumentId = "TEMPLATE_DOC2_ID_GOES_HERE" //ID of template document that should to be replaced
}
}
}
}
});
Envelope is successfully sent, signers can see both new documents, but there are no Tags that were configured in the Template (on Docusign Web UI), and I'd like to avoid sending recipient tabs from client.
Am I missing something?
Thanks.
Change the sequencing order so the new documents are listed first.
With composite templates, order matters. For documents, the earlier documents are used. -- So your new documents should be before the server template (and its documents).
For everything else, the later information wins.
See this answer: https://stackoverflow.com/a/44376770/64904
On second thought, I see that you're doing this and it is all working except that the tabs are not being applied to the new documents.
Try the merge_roles_on_draft query parameter. Also, if you're using anchor tabs, add the applyAnchorTabs: 'true' element to the document objects.
I'm using DocuSignAPI SDK to send envelopes. I have a few templates defined and they use a Custom Field called MemberFullName.
The field is of type Name, FullName.
For some templates I want MemberFullName map to a Signer's name, but sometimes I want to map another name to it.
My assumption was if I don't map anything to MemberFullName, then Signer's name will be used. But if I add "fullNameTabs" for MemberFullName, then it will be mapped.
Signer sgnr = new Signer()
{
RoleName = "Someone other than Member",
RecipientId = "1",
Name = "Bob Signer",
Email = "bobsemailaddress#yahoo.com"
};
sgnr.Tabs.FullNameTabs = new List<FullName>();
sgnr.Tabs.FullNameTabs.Add(new FullName() { TabLabel = "MemberFullName", Name = "Joe Smith" });
But MemberFullName is still mapped to Signer name in the resulting document.
How can I map a NON-SIGNER name to a field of type "Name"?
I know I can create a different field of type TEXT and map "Joe Smith" to it, but I wanted to reuse the "MemberFullName" field in both situations.
I apologize as I may not be using correct "docusign terminology" for things.
You will not be able to set the value of FullName tab manually. See this answer
for more information.
Is there a function in Suitescript using which we would get all the fields or columns belonging to the object (i.e. location, account, transaction etc.)
You can use the function getAllFields() of the record to retrieve all the fields for that record.
var fields = nlapiGetNewRecord().getAllFields()
// loop through the returned fields
fields.forEach(function(fieldName){
var field = record.getField(fieldName);
var fieldlabel = field.getLabel();
if(fieldlabel=='something'){
//do something here
return;
}
}
you can also get the list of available fields for a record here