Trying to source the Email Template `fieldid: emai...
# suitescript
s
Trying to source the Email Template
fieldid: emailbodylayout
from the Custom Form on a user event script. Any suggestions on how I could achieve that? I’m able to pull the custom form internal id however can’t get to the related table/join. Ex -
customform.emailbodylayout
gives me errors.
b
not quite sure where you are starting from, but only searches and queries do joins
s
I’m on an
afterSubmit
UE script that sends email with Transaction PDF. Want to default the email body/subject to the email template that is selected on the transaction form. By using
render.mergeEmail({ templateId: <REQUIRED>, transactionId: <REQUIRED>})
I’m able to get the email body/subject but I want to dynamically source the
templateId
from the transaction form. Hopefully, that makes sense.
b
forms are one of the least scriptable things there are
s
if your field is on the record context.newRecord.getValue will probably get it
s
@battk my fear. lol.
@Sciuridae54696d i’m able to pull the internal id of the form on the record but can’t get the
emailbodylayout
associated with the form to show up. it errors out.
The error >> ERROR: Field ‘customform.emailbodylayout’ Not Found
s
no wait im just confused, the form you speak of is a suitelet?
and why are you trying to do a join?
i'm confused because if it was just UE, within context, you have the record, i.e context.newRecord or context.oldRecord, within that is already the record for you to getValue
if it was a suitelet or a field from UE using N/ui/serverWidget, i guess it might be different
s
@Sciuridae54696d the form is just the regular transaction form but the field on the transaction record where you can pick the form is
customform
I’m trying to do the join to source the default email template associated with the email form.
s
ok, so in you afterSubmit function, if the argument is context, you can try to pass context.newRecord.getValue('emailbodylayout')
s
Different Invoice forms (or transaction forms) can have different email templates
s
no ok i get u
can you load the form @battk
s
I’ll try to do the emailbodylayout, but when i look at the record object viewer, there’s no field called
emailbodylayout
b
he wants
👍 1
and is essentially doomed
s
the most native way i can think of is use the render module
when you render it using transaction it might process via this setting
I mean render.transaction
s
Copy code
// Render template to get Email Subject and Body
      var template = render.mergeEmail({
        templateId: EMAIL_TEMPLATE_ID,
        transactionId: rec.id,
      });
      options.subject = template.subject;
      options.body = template.body;
I’ll see if I can not include templateId and see if it defaults to the transactionId form.
s
yea
so actually my also 2cents is once you use this, you dont have to use it completely
although template.body is readonly options.body isn't
s
render.doMergeEmail: Missing a required argument: options.templateId
so i do need templateId.
210 Views