• Mayank07
  • NEWBIE
  • 10 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 7
    Replies
Hi Folks,
I am creating website using Lightning web component (LWC) on communities that has a number of pages.
I want to track the activities on each page using pardot tracking code. But seems like it is not possible add it directy as it contains script tags which is not allowed in LWC.
Below is the code of one of the pages:
<template>
 <div class="evencorner-bg">
 <h1 class="eventcorner_h1_c-suite">Inside Leadership</h1>
 </div>
 <div class="row">
<template for:each={leaderShipArray} for:item='item'>
 <div key={item.Id} data-id={item.Id}>
 <div class="column xscol_global">
        <img src={item.Event_Banner__c} class="largeimgcss" />
        <div class="margintopdivlarge">
        <br/> <p class="trendingvidtext">inside leadership</p>
        <br/> <p class="largeimgtextsubp1">{item.Name}</p>
        <br/> <div class="largeimgtextsubp2">{item.Short_Event_Description__c} </div>
        </div>  
        <div class="row insideleadRow">
          <div class="column insideleadCol1">
          <img src={calendarIcon} class="Icon_img" /> 
          <lightning-formatted-date-time
          value={item.Event_Start_Date__c}
          time-zone="UTC">
        </lightning-formatted-date-time>
        <span style="margin-left: 5px;">•  <lightning-formatted-date-time 
          value={item.Event_Start_Time__c} 
          hour="2-digit" 
          minute="2-digit"
          time-zone="UTC" 
          ></lightning-formatted-date-time></span>
          </div>
          <div class="column insideleadCol2">
          <a class="insideleadregbtn" href={item.DetailURL__c}>Register Now</a>
          </div>
          </div>
        </div>
 </div>
 </template>
 </div>
</template>

When i add my pardot campaign tracking code right before the </template> at the end, i get the following errors
LWC1051: Forbidden tag found in template: '<script>' tag is not allowed.
 
Invalid expression { function async_load(){ var s = document.createElement('script'); s.type = 'text/javascript'; s.src = ('https:' == document.location.protocol ? 'https://pi' : 'http://cdn') + '.pardot.com/pd.js'; var c = document.getElementsByTagName('script')[0]; c.parentNode.insertBefore(s, c); } - LWC1060: Template expression doesn't allow FunctionExpression

Please help me how can add my tracking code here.
It would be great help.
​​​​​​​Thanks​​​​​​​
I am allocating a customer community user license whenever a lead is converted into contact and it's working fine. below is my code:
trigger CreateCommunityUser on Contact (After insert) {
    
if(Trigger.isInsert){
         for(Contact co : trigger.new){
Contact con = [select id,email,firstName,lastname,accountId from Contact where Id =:co.Id];         
Database.DMLOptions dmo = new Database.DMLOptions();
dmo.EmailHeader.triggerUserEmail = false;       
dmo.EmailHeader.triggerOtherEmail = false;
dmo.EmailHeader.triggerAutoResponseEmail = false;       
dmo.optAllOrNone = false; */

// create portal user
string nick = con.email!=null?con.email.substring(0, con.email.indexOf('@')):'';
nick += Datetime.now().getTime();
User newUser1 = new User(alias=con.firstName, email = con.email, emailencodingkey = 'UTF-8', firstname = con.firstName, lastname = con.lastname, languagelocalekey = 'en_US',localesidkey = 'en_US',contactId = con.Id,timezonesidkey = 'Asia/Dubai',username = con.email,CommunityNickname = nick,ProfileId ='00e6F000001kZ4C', IsActive = true);
newUser1.setOptions(dmo); 
insert newUser1;
         }
     }
}

Because of this code, most of my other test classes are failing with these errors:
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, CreateCommunityUser: execution of AfterInsert
caused by: System.DmlException: Insert failed. First exception on row 0; first error: STRING_TOO_LONG, Alias: data value too large: FirstName (max length=8): [Alias]
Trigger.CreateCommunityUser: line 16, column 1: []

Please guide me where am I going wrong.
Thanks already.
I have built a custom community site and want to add my tracking code from Pardot to the site along with a form to capture the prospects. Is it possible? If yes where do I add the tracking code and how to do I add my pardot form or form handler to it.
Hi, i am creating three child records when a record is created on parent object using process builder. now,  i am writing a trigger to update 'status__c = closed' field on parent object when status of three child record's is marked as 'completed'. 
below is my apex method
public class StatusClosedHandler { 
     public static void statuschange(List<Id> RecordId){ 
         integer count = 0; 
         List<Service_Request__c> srequest = new List<Service_Request__c>();
         for(Service_Line__c sl : [Select id, Name, Status__c,Line_Type__c, Service_Request__r.Status__c,Service_Request__r.Name from Service_Line__c WHERE Id IN :RecordId]){
         if(sl.Status__c == 'Completed'){ 
         count++;
 } 
         if(count == 3){
         Service_Request__c sr = new Service_Request__c();
         sr.id = sl.Service_Request__c;
         sr.status__c = 'Closed';
         srequest.add(sr);
 } 
 }
          update srequest;
 } 
}

and my trigger to call this method is :
trigger StatusClosedfinal on Service_Line__c (after update) {
    if(Trigger.isAfter && Trigger.isUpdate){ 
   List<Id> sLine = new List<Id>();
    for(Service_Line__c  i:trigger.new) {
        sLine.add(i.Id);
}
     StatusClosedHandler.statuschange(sLine); 
} 
}

when i am running method in anonymous window and passing parent id as a list, it's updating the status, but not while runnig the trigger.
​​​​​​​please help
Guys Please help why i am getting this error when i am firing the trigger.. and what's the possible work around? here's my code
trigger ServiceRequestEmail on Service_Request__c (after update) {
    
 /*   List<Id> sRequest = new List<Id>();
    for(Service_Request__c  i:trigger.new) {
        sRequest.add(i.Id);
}
   List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
                for(Service_Request__c sR : Trigger.new){
                if(sR.Status__c == 'Closed' && sR.Customer_Email__c !=null){
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                List<String> sendTo = new List<String>();
                sendTo.add(sR.Customer_Email__c);
                mail.setToAddresses(sendTo); 
                mail.setReplyTo('think4u007@gmail.com');
                mail.setSenderDisplayName('ASD Servicing Company');
                List<String> ccTo = new List<String>();
                ccTo.add('mayanktripathi201194@gmail.com');
                mail.setCcAddresses(ccTo);
                mail.setSubject('Billing Deatils for the Servicing with ASD Company ');
                String body = '<html><body>Dear ' + sR.Name + ' It was a pleause to assist you with your Vehicle servicing.<br><br>Below are the details of Your biliing : <br> Oil Check & Touchup Cost: ' + sR.Oil_Checks_Touchup_Cost__c + ' <br> Total External Repair Cost: ' + sR.Total_External_Repair_Cost__c + ' <br> Total Interior Repair Cost: ' + sR.Total_Internal_Repair_Cost__c + ' <br> Effort Required by the Serviceman: ' + sR.Total_Effort_Required__c + ' <br> Overall Vehicle Servicing Cost: ' + sR.Total_Repair_Cost__c + ' <br> Thanks for Visiting us. <br><br>Have a Nice Day!</body></html>';
                mail.setHtmlBody(body);
                mails.add(mail);
   }          
  } 
               
  
       Messaging.sendEmail(mails); 


}

 
can anyone please tell me how to fix the issue.
my Apex method is
public class ServiceRequestEmailHandler {
  public static void sendSingleEmail(List<Id> RecordId){
                List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
                for(integer i=0; i<RecordId.size(); i++) {
                for(Service_Request__c sR : [Select id, Name, Status__c, Customer_Email__c, Oil_Checks_Touchup_Cost__c, Total_External_Repair_Cost__c, Total_Internal_Repair_Cost__c, Total_Effort_Required__c, Total_Repair_Cost__c FROM Service_Request__c  WHERE Id = :RecordId[i] ]){
                if(sR.Status__c == 'Closed' && sR.Customer_Email__c !=null){
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                List<String> sendTo = new List<String>();
                sendTo.add(sR.Customer_Email__c);
                mail.setToAddresses(sendTo); 
                mail.setReplyTo('think4u007@gmail.com');
                mail.setSenderDisplayName('ASD Servicing Company');
                List<String> ccTo = new List<String>();
                ccTo.add('mayanktripathi201194@gmail.com');
                mail.setCcAddresses(ccTo);
                mail.setSubject('Billing Deatils for the Servicing with ASD Company ');
                String body = '<html><body>Dear ' + sR.Name + ' It was a pleause to assist you with your Vehicle servicing.<br><br>Below are the details of Your biliing : <br> Oil Check & Touchup Cost: ' + sR.Oil_Checks_Touchup_Cost__c + ' <br> Total External Repair Cost: ' + sR.Total_External_Repair_Cost__c + ' <br> Total Interior Repair Cost: ' + sR.Total_Internal_Repair_Cost__c + ' <br> Effort Required by the Serviceman: ' + sR.Total_Effort_Required__c + ' <br> Overall Vehicle Servicing Cost: ' + sR.Total_Repair_Cost__c + ' <br> Thanks for Visiting us. <br><br>Have a Nice Day!</body></html>';
                mail.setHtmlBody(body);
                mails.add(mail);
   }          
  } 
               
 } 
       Messaging.sendEmail(mails);
} 
}

And my trigger is
trigger ServiceRequestEmail on Service_Request__c (after update) {
    
    List<Id> sRequest = new List<Id>();
    for(Service_Request__c  i:trigger.new) {
        sRequest.add(i.RecordTypeId);
}
    ServiceRequestEmailHandler.sendSingleEmail(sRequest); 
}

​​​​​​​
I got 2 objects Service_Request__c(Parent) and Service_Line__c(Child). All I'm trying to do is update a field of parent object from child.based on the following condition.
In the following code, I'm not getting how to update the parent.
please suggest how to proceed.
public class StatusClosedHandler {
    public static void statuschange (String RecordId){
        integer count = 0;
        List<Service_Line__c> sLine = new List<Service_Line__c>();
     for(Service_Line__c sl : [Select id, Name, Status__c,Line_Type__c, Service_Request__r.Status__c,Service_Request__r.Name from Service_Line__c WHERE Service_Request__c = :RecordId ]){
         if(sl.Status__c == 'Completed'){
             count++; 
    }
             if(count == 3){  
             sl.Service_Request__r.Status__c = 'Closed';   
    }
             sLine.add(sl);
    }
             update sLine;
    }
  }

 
I have a master-detail relationship between Service_Request__c(Parent) & Service_Line__c(Child). for each child record there are three records created (Line_Type__c :- Line A Type, Line B Type, Line C Type). there's a field Status__c in the child Object which corresponds to each of the three records created. how to access the relationship between Each Line type record with their status?. here i want to check if for every Line_Type__c the status__c is 'Completed' so that the Parent object's (Service_Request__c) Status can be updated to 'Closed'.  
for(Service_Line__c sl : [Select id, Name, Status__c,Line_Type__c, Service_Request__r.Status__c,Service_Request__r.Name from Service_Line__c ]){
          if( sl.Status__c == 'Completed') {
           sl.Service_Request__r.Status__c = 'Closed';
          }

 
I am trying to update a Picklist value "status ='Closed'" of a custom object Service_Request__c based on Picklist value "Status = 'Completed' on Service_Line__c record, basically this should happen after I update Status = 'Completed' on Service_Line__c. Service_Line__c Custom Object has a Master-Detail with Service_Request__c. Thanks in Advance.
Hi Folks,
I am creating website using Lightning web component (LWC) on communities that has a number of pages.
I want to track the activities on each page using pardot tracking code. But seems like it is not possible add it directy as it contains script tags which is not allowed in LWC.
Below is the code of one of the pages:
<template>
 <div class="evencorner-bg">
 <h1 class="eventcorner_h1_c-suite">Inside Leadership</h1>
 </div>
 <div class="row">
<template for:each={leaderShipArray} for:item='item'>
 <div key={item.Id} data-id={item.Id}>
 <div class="column xscol_global">
        <img src={item.Event_Banner__c} class="largeimgcss" />
        <div class="margintopdivlarge">
        <br/> <p class="trendingvidtext">inside leadership</p>
        <br/> <p class="largeimgtextsubp1">{item.Name}</p>
        <br/> <div class="largeimgtextsubp2">{item.Short_Event_Description__c} </div>
        </div>  
        <div class="row insideleadRow">
          <div class="column insideleadCol1">
          <img src={calendarIcon} class="Icon_img" /> 
          <lightning-formatted-date-time
          value={item.Event_Start_Date__c}
          time-zone="UTC">
        </lightning-formatted-date-time>
        <span style="margin-left: 5px;">•  <lightning-formatted-date-time 
          value={item.Event_Start_Time__c} 
          hour="2-digit" 
          minute="2-digit"
          time-zone="UTC" 
          ></lightning-formatted-date-time></span>
          </div>
          <div class="column insideleadCol2">
          <a class="insideleadregbtn" href={item.DetailURL__c}>Register Now</a>
          </div>
          </div>
        </div>
 </div>
 </template>
 </div>
</template>

When i add my pardot campaign tracking code right before the </template> at the end, i get the following errors
LWC1051: Forbidden tag found in template: '<script>' tag is not allowed.
 
Invalid expression { function async_load(){ var s = document.createElement('script'); s.type = 'text/javascript'; s.src = ('https:' == document.location.protocol ? 'https://pi' : 'http://cdn') + '.pardot.com/pd.js'; var c = document.getElementsByTagName('script')[0]; c.parentNode.insertBefore(s, c); } - LWC1060: Template expression doesn't allow FunctionExpression

Please help me how can add my tracking code here.
It would be great help.
​​​​​​​Thanks​​​​​​​
Guys Please help why i am getting this error when i am firing the trigger.. and what's the possible work around? here's my code
trigger ServiceRequestEmail on Service_Request__c (after update) {
    
 /*   List<Id> sRequest = new List<Id>();
    for(Service_Request__c  i:trigger.new) {
        sRequest.add(i.Id);
}
   List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
                for(Service_Request__c sR : Trigger.new){
                if(sR.Status__c == 'Closed' && sR.Customer_Email__c !=null){
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                List<String> sendTo = new List<String>();
                sendTo.add(sR.Customer_Email__c);
                mail.setToAddresses(sendTo); 
                mail.setReplyTo('think4u007@gmail.com');
                mail.setSenderDisplayName('ASD Servicing Company');
                List<String> ccTo = new List<String>();
                ccTo.add('mayanktripathi201194@gmail.com');
                mail.setCcAddresses(ccTo);
                mail.setSubject('Billing Deatils for the Servicing with ASD Company ');
                String body = '<html><body>Dear ' + sR.Name + ' It was a pleause to assist you with your Vehicle servicing.<br><br>Below are the details of Your biliing : <br> Oil Check & Touchup Cost: ' + sR.Oil_Checks_Touchup_Cost__c + ' <br> Total External Repair Cost: ' + sR.Total_External_Repair_Cost__c + ' <br> Total Interior Repair Cost: ' + sR.Total_Internal_Repair_Cost__c + ' <br> Effort Required by the Serviceman: ' + sR.Total_Effort_Required__c + ' <br> Overall Vehicle Servicing Cost: ' + sR.Total_Repair_Cost__c + ' <br> Thanks for Visiting us. <br><br>Have a Nice Day!</body></html>';
                mail.setHtmlBody(body);
                mails.add(mail);
   }          
  } 
               
  
       Messaging.sendEmail(mails); 


}

 
can anyone please tell me how to fix the issue.
my Apex method is
public class ServiceRequestEmailHandler {
  public static void sendSingleEmail(List<Id> RecordId){
                List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
                for(integer i=0; i<RecordId.size(); i++) {
                for(Service_Request__c sR : [Select id, Name, Status__c, Customer_Email__c, Oil_Checks_Touchup_Cost__c, Total_External_Repair_Cost__c, Total_Internal_Repair_Cost__c, Total_Effort_Required__c, Total_Repair_Cost__c FROM Service_Request__c  WHERE Id = :RecordId[i] ]){
                if(sR.Status__c == 'Closed' && sR.Customer_Email__c !=null){
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                List<String> sendTo = new List<String>();
                sendTo.add(sR.Customer_Email__c);
                mail.setToAddresses(sendTo); 
                mail.setReplyTo('think4u007@gmail.com');
                mail.setSenderDisplayName('ASD Servicing Company');
                List<String> ccTo = new List<String>();
                ccTo.add('mayanktripathi201194@gmail.com');
                mail.setCcAddresses(ccTo);
                mail.setSubject('Billing Deatils for the Servicing with ASD Company ');
                String body = '<html><body>Dear ' + sR.Name + ' It was a pleause to assist you with your Vehicle servicing.<br><br>Below are the details of Your biliing : <br> Oil Check & Touchup Cost: ' + sR.Oil_Checks_Touchup_Cost__c + ' <br> Total External Repair Cost: ' + sR.Total_External_Repair_Cost__c + ' <br> Total Interior Repair Cost: ' + sR.Total_Internal_Repair_Cost__c + ' <br> Effort Required by the Serviceman: ' + sR.Total_Effort_Required__c + ' <br> Overall Vehicle Servicing Cost: ' + sR.Total_Repair_Cost__c + ' <br> Thanks for Visiting us. <br><br>Have a Nice Day!</body></html>';
                mail.setHtmlBody(body);
                mails.add(mail);
   }          
  } 
               
 } 
       Messaging.sendEmail(mails);
} 
}

And my trigger is
trigger ServiceRequestEmail on Service_Request__c (after update) {
    
    List<Id> sRequest = new List<Id>();
    for(Service_Request__c  i:trigger.new) {
        sRequest.add(i.RecordTypeId);
}
    ServiceRequestEmailHandler.sendSingleEmail(sRequest); 
}

​​​​​​​
I got 2 objects Service_Request__c(Parent) and Service_Line__c(Child). All I'm trying to do is update a field of parent object from child.based on the following condition.
In the following code, I'm not getting how to update the parent.
please suggest how to proceed.
public class StatusClosedHandler {
    public static void statuschange (String RecordId){
        integer count = 0;
        List<Service_Line__c> sLine = new List<Service_Line__c>();
     for(Service_Line__c sl : [Select id, Name, Status__c,Line_Type__c, Service_Request__r.Status__c,Service_Request__r.Name from Service_Line__c WHERE Service_Request__c = :RecordId ]){
         if(sl.Status__c == 'Completed'){
             count++; 
    }
             if(count == 3){  
             sl.Service_Request__r.Status__c = 'Closed';   
    }
             sLine.add(sl);
    }
             update sLine;
    }
  }

 
I am trying to update a Picklist value "status ='Closed'" of a custom object Service_Request__c based on Picklist value "Status = 'Completed' on Service_Line__c record, basically this should happen after I update Status = 'Completed' on Service_Line__c. Service_Line__c Custom Object has a Master-Detail with Service_Request__c. Thanks in Advance.