0

I'm redirecting the user from my lightning component to Lightning Email template creation popup. Currently, the user has access to create there own from setup but to eliminate going to setup, I've set a redirect to the lightning email template creation page using $A.get("e.force:navigateToURL")

Following is the code,

onNewEmailTempCreate : function(component, event, helper) {
        var sel = component.find("Template").get("v.value");
        if(sel === 'New Email Template'){
            var urlEvent = $A.get("e.force:navigateToURL");
            urlEvent.setParams({
                "url": "/lightning/o/EmailTemplate/new?count=1&nooverride=1&useRecordTypeCheck=1&navigationLocation=LIST_VIEW&backgroundContext=%2Flightning%2Fo%2FEmailTemplate%2Fhome"
            });
            urlEvent.fire();
        }

    },

This code is working fine in redirecting and showing the creation page but I see following error when saving, "Template Unique Name must be provided.: Template Unique Name RelatedEntityType can only be specified for SFX Custom Templates.: Custom Object Definition ID"

enter image description here

The name i'm using is unique and doesn't already exist.

Please let me know if i'm missing something.

1

as said in the error you need to set the 'UiType'(Indicates the user interface where this template is usable) to 'SFX' and 'TemplateType' to custom you can do this

onNewEmailTempCreate : function(component, event, helper) {

        var createAcountContactEvent = $A.get("e.force:createRecord");
        createAcountContactEvent.setParams({
            "entityApiName": "EmailTemplate",
            "defaultFieldValues": {
                'UiType' :'SFX',
                'TemplateType':'custom'



            }
        });
        createAcountContactEvent.fire();

    }
| improve this answer | |
  • Thank you for the solution, do you if this can be opened in a new tab instead of current page? – Anurag Mar 31 at 16:58
  • @Anurag if you will launch above event in console app it will automatically take you to different tab,in nomal app the best i can think of is you can launch another component on button click and in init of other component fire this event which will open it in another tab but still in popup – User6670 Mar 31 at 18:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.