Step 1: Create Custom Record Type as child of Customer Record
- Create a Custom Record Type > Make sure to set Enable Mail Merge = true
- Create a field under this record type. Set the ff:
- Type = List/Record
- List/Record = Customer
- Record is Parent = true Display subtab > Parent Subtab > a subtab created under (Customization > Forms > Subtabs > Entity)
- Create another field under this record type.
- Save. Process 1-4 will create a custom record with 2 field and where Parent record is Customer.
- Set Type = Free Form Text
Step 2 : Create the email template as below and save to File Cabinet. When the mergeTemplate is sent, it should show the date where the custom record was created, the string field if Step3 (if populated) and the Customer (recordType and internalid)
Date Created:
License Key String:
Customer id: -
Thanks,
Juan Dela Cruz
Step 3 : Execute the script below in the Debugger, valid internal id's should be populated appropriately (see help guide for nlapiMergeRecord definition), note that it will throw RCRD_DSNT_EXIST error that as if the custom record could not be properly merge with customer record or that invalid internal id's were used.
nlapiLogExecution('DEBUG','msg = ',msg);
nlapiSendEmail( -5,'sampleemail@test.com','MERGE SAMPLE', msg , null, null, null );
nlapiLogExecution('DEBUG','email sent = ','ok');
The baseType in this particular use case needs to be the custom record since when you hit Merge and Send button from custom record, you need to specify a particular customer which makes it one-to-one relationship. Doing the same thing from the Customer record, a user does not have the capability to select from the custom records attached to it which makes it one-to-many relationship making the fields in the fields in the custom record null during the merge.
Correct Code:
nlapiLogExecution('DEBUG','msg = ',msg);
nlapiSendEmail( -5,'sampleemail@test.com','MERGE SAMPLE', msg , null, null, null );
nlapiLogExecution('DEBUG','email sent = ','ok');
No comments:
Post a Comment