• Samuel Robert 15
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 3
    Replies
We have a requirement to build a custom visualforce component for VF email template and in that we are trying to display a lightning component. The lightning component is visible when we preview the vf page , however when we try send sample email the email template wont display the component section alone.
Not sure if that is a limit in salesforce.
Please advise.

VF Email template:
<messaging:emailTemplate subject="Panasonic approval notification" recipientType="User" relatedToType="Opportunity">
<messaging:htmlEmailBody > <c:CustomEmailapprovernameVFC relatedToId="{!relatedTo.id}"/> ,

You have approval request for new SPA number {!relatedTo.PLSI_CRM_ID__c} Project Name :- {!relatedTo.Name} of Rs.Total amount :- {!relatedTo.Amount} of Panasonic Project Value.

CRM Number: {!relatedTo.PLSI_CRM_ID__c}
CRM Date : {!relatedTo.CreatedDate}
Project Name : {!relatedTo.Name}
Site Delivery Address : {!relatedTo.PLSI_Site_Address__c}

<c:CustomEmailtemplateVF relatedToId="{!relatedTo.id}"/>
Item Brand Panasonic Discount % Panasonic Discounted Amount DC Offer Competitor Name Competitor Range Competitor Discount % Competitor Discounted Amount {!oppline.Product2.ProductCode} {!oppline.Product2.PLSI_Brand__c} {!oppline.Discount} {!oppline.TotalPrice} {!oppline.Dealer_Coverage__c} {!oppline.Competitor_Name__c} {!oppline.Competitor_range__c} {!oppline.Discount_Offered__c} {!oppline.Competitor_Total_after_discount__c}
CustomEmailtemplateVF:
<apex:component access="global" controller="Approvalnotificationdetails">
<apex:attribute name="relatedToId" assignTo="{!targetObjectId}" type="String" description="ID of the opportunitydetils to retrieve"/>

<apex:includeLightning />
<div style="width:100%;height:100px;" id="LightningContainer" /> 
<script> 
   alert('{!targetObjectId}')
    $Lightning.use("c:ConsignmentChartapp", function() {
        
        $Lightning.createComponent("c:ConsignmentChart", 
        {
              
            foremailtemplate:true,
            opportunityid :'{!targetObjectId}'
          
        },
        "LightningContainer",
        function(cmp) {
            alert('Component created');
            //cmp.set("v.opId" , "0061e0000033NTb");
            //cmp.set("v.foremailtemplate",true); 
        }); 
    });
</script>
</apex:component>
CustomEmailapprovernameVFC:
<apex:component access="global" controller="Approvalnotificationdetails">
<apex:attribute name="relatedToId" assignTo="{!targetObjectId}" type="String" description="ID of the opportunitydetils to retrieve"/>
Hi,<apex:outputText value="{!approvername}"/>
</apex:component>
ApprovalNotificationDetail class:
public class Approvalnotificationdetails {
public ID targetObjectId { get; set; }
public String approvername {
    get {
        if (approvername == null) {
            ProcessInstance lastStep = getLastApprovalStep();
            System.debug('StepsAndWorkitems'+ lastStep);
            String approverid = ( lastStep != null ) ? lastStep.StepsAndWorkitems[0].ActorId : '';
            if(approverid !=null){ 
                List<User> approveruser  = [Select Name from User where id = :approverid and IsActive = true]; 
                if(approveruser.size()>0){
                    for(User approver:approveruser ){
                        approvername = approver.Name;
                    }
                }
            }
        }
        System.debug('approvername-->'+approvername);
        return approvername;
    }
    private set;
}
private ProcessInstance getLastApprovalStep() {
    List<ProcessInstance> steps = new List<ProcessInstance>([
        SELECT
        Id,(select id, ActorId from StepsAndWorkitems where StepStatus = 'Pending' LIMIT 1)
        FROM
        ProcessInstance
        WHERE
        TargetObjectId = :targetObjectId 
        ORDER BY
        SystemModStamp DESC
        LIMIT
        1
    ]);
    System.debug('steps-->'+steps);
    
    return ( steps.size() > 0 ) ? steps[0] : null;
}
}
ConsignmentChart.App:
<aura:application access="global" extends="ltng:outApp" >
<aura:dependency resource="c:ConsignmentChart"/>
</aura:application>
ConsignmentChart.cmp:
<aura:component controller="ConsignmentChart" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >

<aura:attribute name="opportunityid" type="String"/>
<aura:attribute name ="foremailtemplate" type="Boolean"/>
<aura:attribute name="data" type="Object"/>
<aura:attribute name="odata" type="List"/>
  <aura:attribute name="columns" type="List"/>    
 <aura:attribute name="Others" type="Decimal"/>  
<aura:attribute name="OtherE" type="Decimal"/>
<aura:attribute name="OthersComp" type="Decimal"/>
<aura:attribute name="totalEP" type="Decimal"/>
 <aura:attribute name="totalCP" type="Decimal"/>
<aura:attribute name="var1" type="Double"/>
 <aura:attribute name="var2" type="Double"/>
 <aura:attribute name="totalP" type="Decimal"/>

<aura:attribute name="opId" type="String"/> <aura:handler name="init" value="{! this }" action="{!c.init }" />

<table class="slds-table slds-table--bordered slds-table--striped">
    <thead>
        <tr>
            <th scope="col"><span class="slds-truncate">BusinessUnit</span></th>
             <th scope="col"><span class="slds-truncate">Delear Coverage</span></th>
            <th scope="col"><span class="slds-truncate">Panasonic Expected Value</span></th>
            <th scope="col"><span class="slds-truncate">Panasonic Project Value</span></th>
            <th scope="col"><span class="slds-truncate">Competitor Project Value</span></th>
        </tr>
    </thead>
   <tbody>
        <aura:iteration items="{!v.data}" var="Opportunity">
            <tr>
                <td>WD</td>
                <td>{!Opportunity.WCDelear__c}</td>
                <td>{!Opportunity.PLSI_Expected_value_WD__c}</td>
                <td>{!Opportunity.WD__c}</td>
                 <td>{!Opportunity.WDCompetetoPrice__c}</td>
            </tr>
            <tr>
                <td>WCT</td>
                <td>{!Opportunity.WCTDealerCoverage__c}</td>
                <td>{!Opportunity.PLSI_Expected_value_WCT__c}</td>
                <td>{!Opportunity.WCT__c}</td>
                 <td>{!Opportunity.WCTCompetitorPrice__c}</td>
            </tr>
            <tr>
                <td>SWG</td>
                <td>{!Opportunity.SWGDealerCoveage__c}</td>
                <td>{!Opportunity.PLSI_Expected_value_SWG__c}</td>
                <td>{!Opportunity.SWG__c}</td>
                 <td>{!Opportunity.SWGCP__c}</td>
            </tr>
           <tr>
                <td>CMS</td>
               <td>{!Opportunity.CMSDealerCoverage__c}</td>
                <td>{!Opportunity.PLSI_Expected_value_CMS__c}</td>
                <td>{!Opportunity.CMS__c}</td>
                 <td>{!Opportunity.CMSCP__c}</td>
            </tr>
            <tr>
                <td>IAQ</td>
                <td>{!OpportunityIAQDC__c}</td>                    
                <td>{!Opportunity.PLSI_Expected_value_IAQ__c}</td>
                <td>{!Opportunity.IAQ__c}</td>
                 <td>{!Opportunity.IAQCp__c}</td>
            </tr>
            <tr>
                <td>LIGHTNING</td>
                <td>{!Opportunity.LIGHTNINGDC__c}</td>                    
                <td>{!Opportunity.PLSI_Expected_value_Lighting__c}</td>
                <td>{!Opportunity.LIGHTNING__c}</td>
                 <td>{!Opportunity.LIGHTNINGCP__c}</td>
            </tr>
             <tr>
                <td>Others</td>
                 <td>0</td>
                <td>{!v.OtherE}</td>
                <td>{!Opportunity.OTHERS__c}</td>
                 <td>{!Opportunity.OTHERSCP__c}</td>
            </tr>
             <tr>
                <td>Total</td>
                  <td> </td>
                <td>{!v.totalEP}</td>
                <td>{!Opportunity.Total__c}</td>
                 <td>{!Opportunity.TotalCP__c}</td>
            </tr>
        </aura:iteration>
    </tbody>
</table>
  

</aura:component>
Controller:
({

init: function (component, event, helper) {
   
    
   helper.doFetchContact(component);
   alert(component.get("v.foremailtemplate"));
   if(component.get("v.foremailtemplate")){
        alert(component.get("v.opportunityid")); 
        helper.doFetchContact1(component);
    }
        
        
}

});
Helper:
({
doFetchContact : function(component) {
    var action = component.get('c.showDetails');
    
    component.set("v.opId",component.get("v.recordId"));
    console.log('opID',component.get("v.recordId"));
    action.setParams({
        'opId':component.get("v.recordId"),
        'buNameV':component.get("v.buName")
    })
    action.setCallback(this, function(response){
        var state = response.getState();
        if(state === 'SUCCESS' && component.isValid()){
            
            component.set('v.data', response.getReturnValue());
            //alert('sucess'+response.getReturnValue())
             var records = response.getReturnValue();
             var records1 = response.getReturnValue();
             var records2 = response.getReturnValue();
            records.forEach(function(record) {
              component.set('v.OtherE' ,record.PLSI_Expected_value_BMS__c+record.PLSI_Expected_value_EVC__c+record.PLSI_Expected_value_FAS__c+record.PLSI_Expected_value_IOT__c+record.PLSI_Expected_value_KNX__c+record.PLSI_Expected_value_SyncoNext__c+record.PLSI_Expected_value_Thea__c+record.PLSI_Expected_value_WH__c);
             
            });
            
            records1.forEach(function(record) {        
 component.set('v.totalEP' ,(record.PLSI_Expected_value_WD__c+record.PLSI_Expected_value_WCT__c+record.PLSI_Expected_value_SWG__c+record.PLSI_Expected_value_CMS__c+record.PLSI_Expected_value_IAQ__c+record.PLSI_Expected_value_Lighting__c+record.PLSI_Expected_value_BMS__c+record.PLSI_Expected_value_EVC__c+record.PLSI_Expected_value_FAS__c+record.PLSI_Expected_value_IOT__c+record.PLSI_Expected_value_KNX__c+record.PLSI_Expected_value_SyncoNext__c+record.PLSI_Expected_value_Thea__c+record.PLSI_Expected_value_WH__c+record.PLSI_Expected_value_BMS__c+record.PLSI_Expected_value_EVC__c+record.PLSI_Expected_value_FAS__c+record.PLSI_Expected_value_IOT__c+record.PLSI_Expected_value_KNX__c+record.PLSI_Expected_value_SyncoNext__c+record.PLSI_Expected_value_Thea__c+record.PLSI_Expected_value_WH__c+record.PLSI_SCI_Expected_value__c));
       });
                      
   
             
        }else{
            alert('ERROR'+response.getReturnValue());
            //alert('ERROR');
        }
    });
    $A.enqueueAction(action);
},
doFetchContact1: function(component) {
    var action = component.get('c.showDetails');
    alert(component.get("v.opportunityid"));
    action.setParams({
        'opId':component.get("v.opportunityid"),
        'buNameV':component.get("v.buName")
    })
    action.setCallback(this, function(response){
        var state = response.getState();
        if(state === 'SUCCESS' && component.isValid()){
            
            component.set('v.data', response.getReturnValue());
            //alert('sucess'+response.getReturnValue())
             var records = response.getReturnValue();
             var records1 = response.getReturnValue();
             var records2 = response.getReturnValue();
            records.forEach(function(record) {
              component.set('v.OtherE' ,record.PLSI_Expected_value_BMS__c+record.PLSI_Expected_value_EVC__c+record.PLSI_Expected_value_FAS__c+record.PLSI_Expected_value_IOT__c+record.PLSI_Expected_value_KNX__c+record.PLSI_Expected_value_SyncoNext__c+record.PLSI_Expected_value_Thea__c+record.PLSI_Expected_value_WH__c);
             
            });
            
            records1.forEach(function(record) {        
 component.set('v.totalEP' ,(record.PLSI_Expected_value_WD__c+record.PLSI_Expected_value_WCT__c+record.PLSI_Expected_value_SWG__c+record.PLSI_Expected_value_CMS__c+record.PLSI_Expected_value_IAQ__c+record.PLSI_Expected_value_Lighting__c+record.PLSI_Expected_value_BMS__c+record.PLSI_Expected_value_EVC__c+record.PLSI_Expected_value_FAS__c+record.PLSI_Expected_value_IOT__c+record.PLSI_Expected_value_KNX__c+record.PLSI_Expected_value_SyncoNext__c+record.PLSI_Expected_value_Thea__c+record.PLSI_Expected_value_WH__c+record.PLSI_Expected_value_BMS__c+record.PLSI_Expected_value_EVC__c+record.PLSI_Expected_value_FAS__c+record.PLSI_Expected_value_IOT__c+record.PLSI_Expected_value_KNX__c+record.PLSI_Expected_value_SyncoNext__c+record.PLSI_Expected_value_Thea__c+record.PLSI_Expected_value_WH__c+record.PLSI_SCI_Expected_value__c));
       });
                      
   
             
        }else{
            alert('ERROR'+response.getReturnValue());
            //alert('ERROR');
        }
    });
    $A.enqueueAction(action);
}

});








 
0
Hi I have created a VF page to call a Lightning component. The function of the lightning component is to display value on it based upon the record ID in Lightning page.
Now in Classic UI we are trying to add VF Button when user clicks it it should get the current page ID and show the lightning component. But , when I click on the button the new screen opens and it keeps on loading without displaying the value. At the bottom of the screen we see the error "Lightning out App error in callback function" but we are not loading any files.


VF Page:
<apex:page StandardController="SG_ProductBook__c" >
    <apex:includeLightning />
<div  id="LightningCompContainer" />
<script>
    $Lightning.use("c:SG_ProductComponentApp", function() {
        $Lightning.createComponent("c:SG_ProductComponent", {
        },
        "LightningCompContainer",
        function(component) {
           component.set("v.bookRecord.Id",'{!$CurrentPage.parameters.id}');
        });
    });

</script>
</apex:page>
Lightning App:
<aura:application access="GLOBAL" extends="ltng:outApp" >

 <aura:dependency resource="c:SG_ProductComponent"/>
</aura:application>

Lightning Component:
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,force:hasSObjectName,forceCommunity:availableForAllPageTypes,force:lightningQuickAction,force:appHostable" controller="SG_ProductComponentController" access="global">   

<!-- Attributes -->

<aura:attribute name="communityName" type="String"/>
<aura:attribute name="accessLevel" type="Integer"/>
<aura:attribute name="loading" type="Boolean" default="true"/>
<aura:attribute name="productRecord" type="Object"/>
    <aura:attribute name="bookRecord" type="Object"/>
<aura:attribute name="categories" type="Array"/>
<aura:attribute name="allLines" type="List"/>
<aura:attribute name="versions" type="List"/>
<aura:attribute name="releaseDates" type="Map"/>
<aura:attribute name="selectedVersion" type="Integer"/>
<aura:attribute name="selectedVersionIsDraft" type="Boolean" default="false"/>
<aura:attribute name="showVersionButton" type="Boolean" default="false"/>
<aura:attribute name="selectedVersionStatus" type="String" default="Release"/>
<aura:attribute name="AccIDFromVfPage" type="string"/>

<lightning:button label="Check ID from Vf" onclick="{!c.doAction}"/>

<!-- Handlers and declared events -->    
<aura:handler name="init" value="{! this }" action="{! c.onInit }"/>
<aura:handler name="change" value="{! v.selectedVersion }" action="{! c.onChangeSelectedVersion }"/>

<!-- Libraries -->
<lightning:overlayLibrary aura:id="overlayLib"/>
<lightning:notificationsLibrary aura:id="notifLib"/>

<!-- Display a lightning card with details about the record -->
<div class="Record Details"> 
    <aura:renderIf isTrue="{! v.loading }">
        <lightning:spinner alternativeText="Loading" variant="brand"/>
    </aura:renderIf>
    <div class="slds-grid slds-grid_align-space slds-gutters slds-wrap slds-grid_vertical-align-center">
        <div class="slds-col">
            <aura:renderIf isTrue="{! !v.selectedVersionIsDraft || v.accessLevel >= 1 }"><lightning:button label="PDF Export" iconName="utility:print" onclick="{! c.handlePrint }"/></aura:renderIf>
            <lightning:button label="Compare" iconName="utility:replace" onclick="{! c.handleCompare }"/>
            <aura:renderIf isTrue="{! v.selectedVersionIsDraft &amp;&amp; v.accessLevel >= 1 }"><lightning:button label="Edit Properties" iconName="utility:edit" onclick="{! c.handleEdit }"/></aura:renderIf>
            <aura:renderIf isTrue="{! v.accessLevel >= 1 }"><lightning:button label="Clone" iconName="utility:copy" onclick="{! c.handleClone }"/></aura:renderIf>
        </div>
        <div class="slds-col slds-col_bump-left">                
            <div class="slds-grid slds-grid_vertical">
                <div class="slds-col slds-align_absolute-center" style="margin-bottom: 5px">
                    <span class="{! 'slds-badge '+v.selectedVersionStatus }">{! v.selectedVersionStatus }</span>
                </div>
                <div class="slds-col">
                    <aura:renderIf isTrue="{! v.showVersionButton }">
                        <lightning:button label="{! v.selectedVersionIsDraft ? 'Release version' : 'New Version' }" iconName="{! v.selectedVersionIsDraft ? 'utility:check' : 'utility:new' }" onclick="{! c.handleVersionButton }"/>
                    </aura:renderIf>
                </div>
            </div>                                  
        </div>
        <aura:renderIf isTrue="{! !(v.accessLevel == 0 &amp;&amp; v.bookRecord.SG_HistoryVersionNumber__c == 0) }">
            <div class="slds-col">
                <lightning:select name="select" label="Select a Version" value="{! v.selectedVersion }">
                    <aura:iteration items="{! v.versions }" var="ver">
                        <option text="{! ver.label }" value="{! ver.id }" selected="{! ver.selected }"/>
                    </aura:iteration>
                </lightning:select>
            </div>
        </aura:renderIf>
    </div> 
    <lightning:card>
        <c:SG_ProductComponent_Card bookRecord="{! v.bookRecord }"/> 
        <aura:iteration items="{! v.categories }" var="aCategory" >
            <c:SG_ProductComponent_Category category="{! aCategory.SG_ProductProperty__r.SG_Category__c }" productBookId="{! v.bookRecord.Id }" selectedVersion="{! v.selectedVersion }" lines="{! v.allLines }"/>
        </aura:iteration>
        <c:SG_ProductComponent_CalculatedFields productBookId="{! v.bookRecord.Id }" lines="{! v.allLines }"/>
    </lightning:card>
</div> 
</aura:component>
Controller:
({
/*
 *  Component initialization 
 *  Launches a different function depending on what type of page the component is displayed
 */
onInit : function(component, event, helper) {
    helper.getAccessLevel(component, event, helper);               
},

/*
 *  On selection of a version, requests the property values for said version
 */    
onChangeSelectedVersion : function(component, event, helper) {
    if(component.get('v.selectedVersion') != '' && component.get('v.bookRecord.Id') != null){      
        helper.setSelectedVersionStatus(component, event, helper);       
        helper.setShowButtons(component, event, helper); 
        helper.getProductPropertyValues(component, event, helper);       
    }       
}, 

/*
 *  Handles opening a new window previewing the product book as pdf
 */
handlePrint : function(component, event, helper) {        
    var url;
    if(component.get('v.communityName') != null) url = location.origin + '/' + component.get('v.communityName') + '/apex/SG_PrintBook?Id=' + component.get("v.bookRecord.Id") + '&version=' + component.get("v.selectedVersion");   
    else url = location.origin + '/apex/SG_PrintBook?Id=' + component.get("v.bookRecord.Id") + '&version=' + component.get("v.selectedVersion");         
    window.open(url, '', '');     
},    

/*
 *  Handles opening a modal for selecting the compare target
 */    
handleCompare : function(component, event, helper) {
    var modalBody;
    $A.createComponent("c:SG_ProductComponent_CompareModal", {"bookRecord": component.get("v.bookRecord"), "accessLevel": component.get("v.accessLevel")},
        function(content, status) {
            if (status === "SUCCESS") {
                modalBody = content;
                component.find('overlayLib').showCustomModal({
                    header: "Select a Product book to compare to",
                    body: modalBody, 
                    showCloseButton: true,
                    cssClass: "slds-modal_large"
                })
            }                               
        });
},

/*
 *  Handles opening a modal for selecting a new name for cloning
 */    
handleClone : function(component, event, helper) {
    var modalBody;
    $A.createComponent("c:SG_ProductComponent_Clone", {"bookRecord": component.get("v.bookRecord"), "accessLevel": component.get("v.accessLevel"), "version": component.get("v.selectedVersion")},
        function(content, status) {
            if (status === "SUCCESS") {
                modalBody = content;
                component.find('overlayLib').showCustomModal({
                    header: "Select a name for the new Product book",
                    body: modalBody, 
                    showCloseButton: true,
                    cssClass: "slds-modal_small"
                })
            }                               
        });
},

/*
 *  Handles opening a modal for editing values
 */    
handleEdit : function(component, event, helper) {
    var modalBody;
    $A.createComponent("c:SG_ProductComponent_EditModal", {"bookRecord": component.get("v.bookRecord"), "properties": component.get("v.allLines")},
        function(content, status) {
            if (status === "SUCCESS") {
                modalBody = content;
                component.find('overlayLib').showCustomModal({
                    header: "Edit "+component.get("v.bookRecord.Name"),
                    body: modalBody, 
                    showCloseButton: true,
                    cssClass: "slds-modal_large",
                    closeCallback: function() {
                       helper.getProductPropertyValues(component, event, helper);
                   }
                })
            }                               
        });
},
        
/*
 *  Handles operations to increment the release version number
 */      
handleVersionButton : function(component, event, helper) {
    if(component.get('v.selectedVersion') == component.get('v.bookRecord.SG_ReleaseVersionNumber__c')+1) helper.releaseVersion(component, event, helper);
    else helper.createNewVersion(component, event, helper);        
}, 
 
doAction : function(component, event, helper) {

    var accIdFromVf=component.get("v.bookRecord.Id");
    alert('Id of record from Vf page'+accIdFromVf);
} })

Please Advice.
Hi,

0
I was trying to create a New knowledge Article through Process builder, When a case status is set to validated.
As a part of creation We are referencing Case custom and standard fields to knowledge article custom and standard field.
I do have knowledge user permission in my user record.
But, still when I created case and set status to Validated it did not created the Article. I do checked for the required Knowledge fields and made sure they are populated on create new record process.
please advise what Iam missing here
Thanks,
 
We have Trigger that calls a future webservice class , which is inturn callsout external system.
When the Account status is set to Active then the system callout the external ITSm sytem and creates a record there . We also maintain Mapping opject to track the ID so in future when the callout fires it will check our system to see if the record is already existing in the other system and performs a Update operation.
However, when we tested the scenario in sandbox it failed in calling the endpoint itself and throws the following error at the apex Jobs
First error: You have uncommitted work pending. Please commit or rollback before calling out
Please find the apex Webservice callout class.
 
global class TOPdeskCalloutObject {
@future (callout=true)
Webservice static void apiCall(String salesforceID, String action, String accountName, String apiType) {

    //Get Username password and URL
    TOPdesk_API__c api = TOPdesk_API__c.getInstance('TOPdeskAPI');        
    String username = api.User_Name__c;
    String password = api.Password__c;
    String TOPdeskURL = api.URL__c;
    String endpoint;
    String method;
    String errorMessage;
    String body ='';
    Boolean archive = FALSE;

    //Construct HTTP request and response
    HttpRequest req = new HttpRequest();
    HttpResponse res = new HttpResponse();
    Http http = new Http();

    //Construct Authorization and Content header
    Blob headerValue = Blob.valueOf(username+':'+password);
    String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);
    req.setHeader('Authorization', authorizationHeader);
    req.setHeader('Content-Type','application/json');

    System.debug('***SalesForce ID: '+ salesForceID);

    //Construct Endpoint
    try {
        TOPdesk_Mapping__c  mapping = [SELECT TOPdesk_Mapping__c.TOPdesk_ID__c FROM TOPdesk_Mapping__c WHERE Name = :salesForceID];
         if (string.isEmpty(mapping.TOPdesk_ID__c)) {
            System.debug('--in is empty--');  
            errorMessage = 'Action = '+action+'<br>API Call = '+method+'<br>Date / Time = '+DateTime.now()+'<br>API Status code = '+res.getStatusCode()+'<br>Response string = '+res.toString()+ ' Json Body = '+res.getBody(); 
            TOPdeskSendMail.sendMail(apiType,'Error = No TOPdesk ID returned '+errorMessage,salesForceID);                    
            return;
         }


        if (action == 'CREATE' && apiType == 'persons') {
            endpoint = TOPdeskURL+'/tas/api/'+apiType+'/id/'+mapping.TOPdesk_ID__c+'/unarchive'; 
            archive = TRUE;
                    System.debug('***CHECK : '+ endpoint + archive);

        }
        if (action == 'ARCHIVE' && apiType == 'persons') {
            endpoint = TOPdeskURL+'/tas/api/'+apiType+'/id/'+mapping.TOPdesk_ID__c+'/archive';         
            archive = TRUE;  
        }
        if (action == 'UPDATE') {
            endpoint = TOPdeskURL+'/tas/api/'+apiType+'/id/'+mapping.TOPdesk_ID__c; 
        }
        method = 'PUT';
        System.debug(endpoint);
        System.debug(method);
    }

     catch(QueryException e) {
        endpoint = TOPdeskURL+'/tas/api/'+apiType;
        method = 'POST';
        System.debug(method);
    }
        System.debug(endpoint);                                 
    //Construct Body     
    if (apiType == 'branches') {
        body = TOPdeskGetAccountBody.getAccount(salesForceID, action);
    }
    if (apiType == 'persons' && archive == FALSE) {
        body = TOPdeskGetContactBody.getContact(salesForceID, action);  
    }

     System.debug('CHECK BODY: '+body);
    //Set Method and Endpoint and Body
    req.setMethod(method);

    if(test.isrunningtest()){
        req.setEndpoint('www.test.com/tas/api/branches');
    }
    else{
        req.setEndpoint(endpoint);
    }

    req.setBody(body);

 // Adding debug statements -[AS] 17/04/2019
    System.debug('endpoint : '+endpoint );
    System.debug('method: '+method);
    System.debug('body: '+body);


    //Send endpoint to TOPdesk
    if(test.isrunningtest()){
       res = getTestResponse(req);
    }
    else{
        res = http.send(req);        
    }


    //Get TOPdeskID from body       
    string responseString = res.getBody();
    System.debug('responseString : '+responseString);
    TOPdeskResponseID responseClass = TOPdeskResponseID.parse(responseString);
    String topdeskID = responseClass.id;

    String statusCode = 'API Status code = '+res.getStatusCode();
    System.debug('API: '+res.getStatusCode());

    errorMessage = 'Action = '+action+'<br>API Call = '+method+'<br>Date / Time = '+DateTime.now()+'<br>API Status code = '+res.getStatusCode()+'<br>Response string = '+res.toString()+ ' Json Body = '+res.getBody(); 
    if (string.isEmpty(topdeskID)) {    
        TOPdeskSendMail.sendMail(apiType,'Error = No TOPdesk ID returned '+errorMessage,salesForceID);
    }

    //Check if TOPdeskID exists in SalesForce mapping table
     try {
    TOPdesk_Mapping__c  mappingID = [SELECT TOPdesk_Mapping__c.ID FROM TOPdesk_Mapping__c WHERE Name = :salesForceID];
        //upsert in case id topdesk id exists
        upsert new TOPdesk_Mapping__c(
        ID = mappingID.ID,
        Name = salesForceID,
        Object_Type__c = apiType,
        TOPdesk_ID__c = topdeskID,
        Object_Name__c = accountName,
        Last_API_Body__c =  body,
        Last_API_Message__c =errorMessage,
        Last_API_Status__c = statusCode 

        );
     } 
     catch(QueryException e) {
        //insert in case no topdesk id is known
        insert new TOPdesk_Mapping__c(
        Name = salesForceID,
        Object_Type__c = apiType,
        TOPdesk_ID__c = topdeskID,
        Object_Name__c = accountName,
        Last_API_Body__c = body,
        Last_API_Message__c =errorMessage,
        Last_API_Status__c = statusCode 
        );
     } 


}

public static HTTPResponse getTestResponse(HTTPRequest req) {
    HttpResponse res = new HttpResponse();
    res.setBody('{"id":"46d05ee6-a56c-489e-9939-8d33d182105f","name":"Dayco, Inc.","specification":"","clientReferenceNumber":"330199","timeZone":"","extraA":null,"extraB":null,"phone":"+1 7166894972","fax":"+1.716.689.1529","address":{"country":null,"street":"1650 Research Dr Ste 200","number":"","county":"MI","city":"Troy","postcode":"48083-2143","addressMemo":"","addressType":null},"email":"","website":"www.dayco.com","postalAddress":{"country":null,"street":"501 J James Adbn Pkwy 400","number":"","county":"NY","city":"Amherst","postcode":"14228","addressMemo":"","addressType":null},"branchType":"independentBranch","headBranch":null,"optionalFields1":{"boolean1":false,"boolean2":false,"boolean3":false,"boolean4":false,"boolean5":false,"number1":0.0,"number2":0.0,"number3":0.0,"number4":0.0,"number5":0.0,"date1":null,"date2":null,"date3":null,"date4":null,"date5":null,"text1":"","text2":"","text3":"","text4":"","text5":"","memo1":null,"memo2":null,"memo3":null,"memo4":null,"memo5":null,"searchlist1":null,"searchlist2":{"id":"b51176b2-885e-4e90-ada9-6e650e26deb9","name":"AMERICAS"},"searchlist3":{"id":"2b5422f6-4864-430f-af87-855d09991820","name":"NA"},"searchlist4":null,"searchlist5":null},"optionalFields2":{"boolean1":false,"boolean2":false,"boolean3":false,"boolean4":false,"boolean5":false,"number1":0.0,"number2":0.0,"number3":0.0,"number4":0.0,"number5":0.0,"date1":null,"date2":null,"date3":null,"date4":null,"date5":null,"text1":"0015000000YG531AAD","text2":"lori.sawatzke=nasdaq.com@example.com","text3":"null","text4":"CREATE","text5":"","memo1":null,"memo2":null,"memo3":null,"memo4":null,"memo5":null,"searchlist1":null,"searchlist2":null,"searchlist3":null,"searchlist4":null,"searchlist5":null},"creator":{"id":"41466b30-30a5-5fd9-bd85-b39fbe09efa9","name":"Breggeman, Joost"},"creationDate":"2019-03-25T09:56:04.937+0000","modifier":{"id":"41466b30-30a5-5fd9-bd85-b39fbe09efa9","name":"Breggeman, Joost"},"modificationDate":"2019-03-25T09:56:04.000+0000"}');
    res.setStatus('OK');
    res.setStatusCode(200);
    return res;
}
}

Apex Trigger :
 
trigger TOPdeskAccountUpdate on Account (after update) {
for (Account a : Trigger.new) {

String salesforceID = a.ID;
String action;
String apiType = 'branches';
System.debug('***SalesForce ID: '+ salesforceID);

//when account status is moved to Active Cust omer
if(trigger.oldMap.get(a.Id).Account_Status__c != a.Account_Status__c && a.Account_Status__c == 'Active Customer' ) {
    action = 'CREATE';
    System.debug('***Action: '+ action);
    TOPdeskCalloutObject.apiCall(salesforceID, action, a.Name, apiType);
    } 
//when Active Customer is updated
else if (trigger.oldMap.get(a.Id).Account_Status__c == a.Account_Status__c && a.Account_Status__c == 'Active Customer') { 
    action = 'UPDATE';
    System.debug('***Action: '+ action);
    TOPdeskCalloutObject.apiCall(salesforceID, action, a.Name, apiType);
   }
//when Active Customer is moved to Inactive
else if (trigger.oldMap.get(a.Id).Account_Status__c != a.Account_Status__c && a.Account_Status__c != 'Active Customer') { 
    action = 'ARCHIVE';
    System.debug('***Action: '+ action);
    TOPdeskCalloutObject.apiCall(salesforceID, action, a.Name, apiType);

    List<Contact> cList = [SELECT ID FROM Contact where accountID=:salesforceID];
        System.debug('***CONTACT: '+ cList); 

    for (Contact c : cList) {
        upsert new Contact(
        ID = c.ID,
        TOPdesk_Contact__c = FALSE);
    }
   }
} }

Please advise
Thanks
Hi,

We have PDF document attached in the Opportunity notes and attachment section in salesforce. When we click on Preview in salesforce classic it wont show us Page 5 and 6 of the PDF.

Similarly, In Lightning when we click on the attachment the quick view wont show us the Page 5 and 6.

But , If we download the PDF file and open it through Adobe /Web it shows the page 5 and 6 .

Is it the limitation of salesforce? How we can overcome this.

Please advise.

Thanks,
 
Hi,

In Classic, email trails were converted to rich/plain text.  In Lightning the previous emails in the trail remain as HTML.  This means that users get an error message when trying to reply (normally on the 3rd reply but not limited to).  Is it possible to either revert the email trail for replies/forwards rich/plain text but still keeping the new message as HTML or - if not - increasing the HTML limit?  What we can and can't do will help us to determine how we create new email templates moving forward.

Please find the screenshot

User-added imageContinued

User-added imagePlease advise.

Thanks,
We made a very minor change to the apex class where we included a field in the Email mathod in the class, however when we tried to deploy we get attempt to de-reference null object error.
Test class:
 
public static testMethod void testUpdateRegistration2(){

Course__c newCourse = new Course__c();
newCourse.Total_Sessions__c = 3;
newCourse.Session_No__c = 001;
newCourse.Registration_Time__c = '8:45AM';
newCourse.Number_of_Days__c = 1;
newCourse.Name = 'Apex Test Course';
newCourse.Minimum_Attendee__c = 5;
newCourse.Maximum_Attendee__c = 10;
newCourse.GST__c = 10;
newCourse.GST_Exempt_Course__c = false;
newCourse.Course_Type__c = 'Face to Face';
newCourse.Course_Start_Time__c = '9:00AM';
newCourse.Course_Number__c = 'C001';
newCourse.Course_End_Time__c = '5:00PM';
newCourse.Course_Classification__c = 'Public';
newCourse.ChargeID__c = 'PRC_999';
newCourse.Category__c = 'Food';
newCourse.Base_Price__c = 999;
insert newCourse;

datetime t = System.now();
date today = Date.newInstance(t.year(),t.month(),t.day());

Class__c newClass = new Class__c();
newClass.Name = 'Apex Test Class';
newClass.Minimim_Attendee__c = 9;
newClass.Maximum_Attendee__c = 99;
newClass.Course_Name__c = newCourse.Id;
newClass.Class_Location__c = 'Sydney';
newClass.Class_Begin_Date__c = today;
newClass.Class_End_Date__c = today;
newClass.Number_of_Confirmed_Attendees__c = 10;
newClass.Class_Status__c = 'Open';
insert newClass;

Account newAccount = new Account();
newAccount.Same_As_Address__c = 'true';
newAccount.Name = 'Apex Test';
//newAccount.ParentId = newAccountParent.Id;
newAccount.Mailing_Zip_Postal_Code__c = '2009'; 
newAccount.Mailing_Street__c = 'Fake Mailing Street';
newAccount.Mailing_State_Province__c = 'NSW';
newAccount.Mailing_Country__c = 'AUSTRALIA';
newAccount.Mailing_City__c = 'Sydney';
newAccount.CurrencyIsoCode = 'AUD';
newAccount.Business_Zip_Postal_Code__c = '1000'; 
newAccount.Business_Street__c = 'Fake Business Street';
newAccount.Business_State_Province__c = 'NSW';
newAccount.Business_Country__c = 'AUSTRALIA';
newAccount.Business_City__c = 'Sydney';
newAccount.Account_Classification__c = 'Business';
insert newAccount;

Account newVenueAccount = new Account();
newVenueAccount.Same_As_Address__c = 'true';
newVenueAccount.Name = 'Apex Venue Test';
newVenueAccount.Mailing_Zip_Postal_Code__c = '2009'; 
newVenueAccount.Mailing_Street__c = 'Fake Mailing Street';
newVenueAccount.Mailing_State_Province__c = 'NSW';
newVenueAccount.Mailing_Country__c = 'AUSTRALIA';
newVenueAccount.Mailing_City__c = 'Sydney';
newVenueAccount.CurrencyIsoCode = 'AUD';
newVenueAccount.Business_Zip_Postal_Code__c = '1000'; 
newVenueAccount.Business_Street__c = 'Fake Business Street';
newVenueAccount.Business_State_Province__c = 'NSW';
newVenueAccount.Business_Country__c = 'AUSTRALIA';
newVenueAccount.Business_City__c = 'Sydney';
newVenueAccount.Account_Classification__c = 'Business';
newVenueAccount.Type = 'Venue';
insert newVenueAccount;

Contact newContact = new Contact();
newContact.FirstName='John';
newContact.LastName='Doe';
newContact.Phone='0299998888';
newContact.Email = 'john.doe@fake.com';
newContact.AccountId = newAccount.Id;
newContact.Dietary_Requirements__c = 'ABC';
insert newContact;

Contact newContact1 = new Contact();
newContact1.LastName='Master';
newContact1.Email = 'a.master@fake.com';
newContact1.Phone = '0288889999';
newContact1.AccountId = newVenueAccount.Id;
insert newContact1;

Contact newContact2 = new Contact();
newContact2.Job_Title__c = 'National Manager';
newContact2.LastName='Master';
//newContact2.Email = 'a.master@fake.com';
newContact2.AccountId = newAccount.Id;
newContact2.MobilePhone = '0499999999';
insert newContact2;

Trainer_Approved_Course__c tac = new Trainer_Approved_Course__c();
tac.Name = 'Apex Trainer Approved Course';
tac.Trainer__c = newContact.Id;
tac.Expiration_Date__c = today + 100000;
tac.Course__c = newCourse.Id;
tac.Approved__c = true;
tac.CurrencyIsoCode = 'AUD';
insert tac;

Trainer_Approved_Course__c tac2 = new Trainer_Approved_Course__c();
tac2.Name = 'Apex Trainer Approved Course 2';
tac2.Trainer__c = newContact2.Id;
tac2.Expiration_Date__c = today + 100000;
tac2.Course__c = newCourse.Id;
tac2.Approved__c = true;
tac2.CurrencyIsoCode = 'AUD';
insert tac2;


Class__c newClass1 = new Class__c();
newClass1.Name = 'Apex Test Class';
newClass1.Minimim_Attendee__c = 9;
newClass1.Maximum_Attendee__c = 99;
newClass1.Course_Name__c = newCourse.Id;
newClass1.Class_Location__c = 'Sydney';
newClass1.Class_Begin_Date__c = today;
newClass1.Class_End_Date__c = today;
newClass1.Number_of_Confirmed_Attendees__c = 10;
newClass1.Class_Status__c = 'Open';
newClass1.Trainer_1__c = newContact.Id;
newClass1.Trainer_2__c = newContact1.Id;
newClass1.Venue__c = newVenueAccount.Id;
newClass1.Num_Material_Ordered__c = 10;
newClass1.Date_Material_Ordered__c = today;
newClass1.Num_in_Stock__c = 10;
newClass1.Num_Material_Printed__c = 5;
newClass1.Num_Standards_Out__c = 10;
newClass1.Num_Standards_In__c = 10;
newClass1.Boxes__c = 2;
newClass1.Job_Reference__c = 'N/A';
newClass1.Date_Material_Sent__c = today;
newClass1.Comments_Materials__c = 'N/A';
insert newClass1;

Id[] originalRegIds = new Id[0];
Registration__c newAttendee = new Registration__c();
newAttendee.Course_Name__c = newCourse.Id;
newAttendee.Attendee__c = newContact.Id;
newAttendee.Class_Name__c = newClass.Id;
newAttendee.Total_Amount__c = 999;
newAttendee.Status__c = 'Confirmed';
insert newAttendee;
originalRegIds.add(newAttendee.Id);

Registration__c newAttendee1 = new Registration__c();
newAttendee1.Course_Name__c = newCourse.Id;
newAttendee1.Attendee__c = newContact.Id;
insert newAttendee1;
originalRegIds.add(newAttendee1.Id);

Registration__c newAttendee2 = new Registration__c();
newAttendee2.Course_Name__c = newCourse.Id;
newAttendee2.Class_Name__c = newClass.Id;
newAttendee2.Attendee__c = newContact.Id;
newAttendee2.Status__c = 'Pended-SAI Cancellation';
insert newAttendee2;
originalRegIds.add(newAttendee2.Id);

Registration__c newAttendee3 = new Registration__c();
newAttendee3.Course_Name__c = newCourse.Id;
newAttendee3.Class_Name__c = newClass1.Id;
newAttendee3.Attendee__c = newContact1.Id;
newAttendee3.Status__c = 'Confirmed';
insert newAttendee3;

Registration__c newAttendee4 = new Registration__c();
newAttendee4.Course_Name__c = newCourse.Id;
newAttendee4.Class_Name__c = newClass1.Id;
newAttendee4.Attendee__c = newContact2.Id;
newAttendee4.Status__c = 'Confirmed';
insert newAttendee4;

Certificate_Template__c newCertificateTemplate = new Certificate_Template__c();
newCertificateTemplate.Name = 'Apex Test Certificate Template';
newCertificateTemplate.CurrencyIsoCode = 'AUD';
insert newCertificateTemplate;

Certificate_Type__c newCertificateType = new Certificate_Type__c();
newCertificateType.Name = 'Statement of Attendance';
newCertificateType.Course_Name__c = newCourse.Id;
newCertificateType.Certificate_Title__c = 'Statement of Attendance';
newCertificateType.Certificate_Template__c = newCertificateTemplate.Id;
newCertificateType.Certificate_Options__c = 'Always Issued';
insert newCertificateType;

// reset governor limit
Test.startTest();

Assessment__c newAssessment = new Assessment__c();
newAssessment.Name = 'Statement of Attendance';
newAssessment.Assessment_Title__c = newCertificateType.Id;
newAssessment.Assessment_Status__c = 'Competent';
newAssessment.Attendee_ID__c = newAttendee.Id;
newAssessment.Assessor__c = newContact.Id;
newAssessment.Received_from_Assessor__c = today;
insert newAssessment;

Assessment_Competency__c newAssessmentCompetency = new Assessment_Competency__c();
newAssessmentCompetency.Name = 'Apex Test Assessment Competency';
newAssessmentCompetency.CurrencyIsoCode = 'AUD';
newAssessmentCompetency.Competency_Code__c = 'ApexTest_9999';
newAssessmentCompetency.Assessment__c = newAssessment.Id;
insert newAssessmentCompetency;

Invoice_ENT__c newInvoiceENT = new Invoice_ENT__c();
newInvoiceENT.Registration__c = newAttendee.Id;
newInvoiceENT.CurrencyIsoCode = 'AUD';
newInvoiceENT.Base_Price__c = 998;
newInvoiceENT.Payment_Status__c = 'c';
newInvoiceENT.Invoice_Type__c = 'ACR';
newInvoiceENT.Bill_Type__c = 'EAR';
insert newInvoiceENT;

Invoice_ENT__c newInvoiceENT1 = new Invoice_ENT__c();
newInvoiceENT1.Registration__c = newAttendee.Id;
newInvoiceENT1.CurrencyIsoCode = 'AUD';
newInvoiceENT1.Base_Price__c = 998;
newInvoiceENT1.Payment_Status__c = 'c';
newInvoiceENT1.Invoice_Type__c = 'REG';
newInvoiceENT1.Bill_Type__c = 'PUB';
insert newInvoiceENT1;

 try{
    Integer processType = 1;
    ClassObj.classcancellation(newClass.Id, processType);
    ClassObj.sendAttendanceList(newClass1.Id);
    ClassObj.sendAttendanceList_TIS(newClass1.Id);
    //System.assertEquals(0, classObj.checkPendingRegos(newClass.Id));
} catch (System.EmailException e){
    System.debug('we caught a email exception: ' + e.getDmlMessage(0));
}

Test.stopTest();
From the above code bold syntax is the line number 1071

Please find the image below of the error I get during deployment.
User-added image
Class:
 
WebService static Id[] sendAttendanceList_TIS(Id ClassId) {

//Modified by sneh@sqwarepeg.com to include more venue and class material details
Class__c classObj = [Select Trainer_1__c, Trainer_1__r.Id, Trainer_1__r.Email,Trainer_1__r.EmailBouncedDate, 
Trainer_1__r.EmailBouncedReason,Trainer2__c, Trainer2__r.Id, Trainer2__r.Email, Trainer2__r.EmailBouncedDate, 
Trainer2__r.EmailBouncedReason, Trainer_2__c, Trainer_2__r.Id, Trainer_2__r.EmailBouncedDate, 
Trainer_2__r.EmailBouncedReason,Trainer_2__r.Email, Id, Venue__r.Id, Venue__r.Name, Venue__r.Business_Street__c, 
Venue__r.Business_City__c, Venue__r.Business_State_Province__c, Venue__r.Business_Zip_Postal_Code__c, 
Venue__r.Business_Country__c, Venue__r.Website, Venue__r.Phone, Venue__r.Internet_Email__c, Venue__r.Comments__c, 
Course_Name__r.Name, Class_Location__c, Class_End_Date__c, Class_Begin_Date__c, Num_in_Stock__c, 
Num_Standards_Out__c, Num_Standards_In__c, Num_Material_Printed__c, Num_Material_Ordered__c, Job_Reference__c, 
Date_Material_Sent__c, Date_Material_Ordered__c, Comments_Materials__c, Boxes__c 
From Class__c where Id =:ClassId];

//Modified by suzan@sqwarepeg.com, validation of the bounced emails
//Modified by sneh@sqwarepeg.com on 12/02/2009 to incorporate the Primary_Venue_Contact__c functionality
Contact[] conObj = [Select Id, Email, AccountId,EmailBouncedDate,EmailBouncedReason From Contact where AccountId =:classObj.Venue__r.Id and Primary_Venue_Contact__c = true];

//Contact[] conObj = [Select Id, Email, AccountId From Contact where AccountId =:classObj.Venue__r.Id];
//Query course field to add them in the Email template.
Course__c crs = [select id,Current_Revision__c from Course__c limit 1];
//if (classObj.Trainer_1__r.Email != null || classObj.Trainer_2__r.Email != null || conObj.Email != null) {
String jobTitle;
String email;
String phone;
String mobile;
String dietaryNeeds;
String accessNeeds;
String HTMLBody;

List<Id> RegIds = new List<Id>();
RegIds = getConfirmedIds(ClassId);

HTMLBody = 'Hi,<br><br>';
HTMLBody = HTMLBody + 'Please find attached the Attendance List for SAI Global\'s course.<br><br>';
HTMLBody = HTMLBody + 'Please print off a copy and hand to the Trainer on the morning of the course.<br><br>';
HTMLBody = HTMLBody + 'If you have any questions please don\'t hesitate to contact our Customer Service Team on 1-800-374-3818.<br><br>';
HTMLBody = HTMLBody + 'Kind Regards,<br>Training and Improvement Solutions<br><br>';
HTMLBody = HTMLBody + '<b><u>Course Information</u></b><br><br>';
if(classObj.Class_End_Date__c != null){
    HTMLBody = HTMLBody + 'Course Name: ' + classObj.Course_Name__r.Name + '<br>' + 'Current Revision:' + crs.Current_Revision__c.format() + '<br>' + 'Class Dates: ' + classObj.Class_Begin_Date__c.day() + '/' + classObj.Class_Begin_Date__c.month() + '/' + classObj.Class_Begin_Date__c.year() + ' - ' + classObj.Class_End_Date__c.day() + '/' + classObj.Class_End_Date__c.month() + '/' + classObj.Class_End_Date__c.year() + '<br>';
} else {
    HTMLBody = HTMLBody + 'Course Name: ' + classObj.Course_Name__r.Name + '<br>' + 'Current Revision:' + crs.Current_Revision__c.format() + '<br>' + 'Class Dates: ' + classObj.Class_Begin_Date__c.day() + '/' + classObj.Class_Begin_Date__c.month() + '/' + classObj.Class_Begin_Date__c.year() + ' - N/A<br>';
}
HTMLBody = HTMLBody + 'Class Location: ' + classObj.Class_Location__c + '<br><br>';

From the above code, The bold Syntax is line 429.

Please advise.

Thanks

 
Hi,

We facing a Page cannot find error in Lightning view of a Task record. But we can see this task in Classic view. Please find the screen shot provided below.

User-added image
The above is the classic view.

User-added image

This is what we get when we try to view the same in the lightning.

Please advise.
Thanks In Advance.
We have a created a Dashboard in lightning however the dashboard is displaying the x-axis revenue data in wrong sequence ,Please find the below image.
User-added image

But, In classic it is showing the correct order, even in the report it is showing the correct format.
Please advise.
Thanks in advance.
0
Hi I have created a VF page to call a Lightning component. The function of the lightning component is to display value on it based upon the record ID in Lightning page.
Now in Classic UI we are trying to add VF Button when user clicks it it should get the current page ID and show the lightning component. But , when I click on the button the new screen opens and it keeps on loading without displaying the value. At the bottom of the screen we see the error "Lightning out App error in callback function" but we are not loading any files.


VF Page:
<apex:page StandardController="SG_ProductBook__c" >
    <apex:includeLightning />
<div  id="LightningCompContainer" />
<script>
    $Lightning.use("c:SG_ProductComponentApp", function() {
        $Lightning.createComponent("c:SG_ProductComponent", {
        },
        "LightningCompContainer",
        function(component) {
           component.set("v.bookRecord.Id",'{!$CurrentPage.parameters.id}');
        });
    });

</script>
</apex:page>
Lightning App:
<aura:application access="GLOBAL" extends="ltng:outApp" >

 <aura:dependency resource="c:SG_ProductComponent"/>
</aura:application>

Lightning Component:
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,force:hasSObjectName,forceCommunity:availableForAllPageTypes,force:lightningQuickAction,force:appHostable" controller="SG_ProductComponentController" access="global">   

<!-- Attributes -->

<aura:attribute name="communityName" type="String"/>
<aura:attribute name="accessLevel" type="Integer"/>
<aura:attribute name="loading" type="Boolean" default="true"/>
<aura:attribute name="productRecord" type="Object"/>
    <aura:attribute name="bookRecord" type="Object"/>
<aura:attribute name="categories" type="Array"/>
<aura:attribute name="allLines" type="List"/>
<aura:attribute name="versions" type="List"/>
<aura:attribute name="releaseDates" type="Map"/>
<aura:attribute name="selectedVersion" type="Integer"/>
<aura:attribute name="selectedVersionIsDraft" type="Boolean" default="false"/>
<aura:attribute name="showVersionButton" type="Boolean" default="false"/>
<aura:attribute name="selectedVersionStatus" type="String" default="Release"/>
<aura:attribute name="AccIDFromVfPage" type="string"/>

<lightning:button label="Check ID from Vf" onclick="{!c.doAction}"/>

<!-- Handlers and declared events -->    
<aura:handler name="init" value="{! this }" action="{! c.onInit }"/>
<aura:handler name="change" value="{! v.selectedVersion }" action="{! c.onChangeSelectedVersion }"/>

<!-- Libraries -->
<lightning:overlayLibrary aura:id="overlayLib"/>
<lightning:notificationsLibrary aura:id="notifLib"/>

<!-- Display a lightning card with details about the record -->
<div class="Record Details"> 
    <aura:renderIf isTrue="{! v.loading }">
        <lightning:spinner alternativeText="Loading" variant="brand"/>
    </aura:renderIf>
    <div class="slds-grid slds-grid_align-space slds-gutters slds-wrap slds-grid_vertical-align-center">
        <div class="slds-col">
            <aura:renderIf isTrue="{! !v.selectedVersionIsDraft || v.accessLevel >= 1 }"><lightning:button label="PDF Export" iconName="utility:print" onclick="{! c.handlePrint }"/></aura:renderIf>
            <lightning:button label="Compare" iconName="utility:replace" onclick="{! c.handleCompare }"/>
            <aura:renderIf isTrue="{! v.selectedVersionIsDraft &amp;&amp; v.accessLevel >= 1 }"><lightning:button label="Edit Properties" iconName="utility:edit" onclick="{! c.handleEdit }"/></aura:renderIf>
            <aura:renderIf isTrue="{! v.accessLevel >= 1 }"><lightning:button label="Clone" iconName="utility:copy" onclick="{! c.handleClone }"/></aura:renderIf>
        </div>
        <div class="slds-col slds-col_bump-left">                
            <div class="slds-grid slds-grid_vertical">
                <div class="slds-col slds-align_absolute-center" style="margin-bottom: 5px">
                    <span class="{! 'slds-badge '+v.selectedVersionStatus }">{! v.selectedVersionStatus }</span>
                </div>
                <div class="slds-col">
                    <aura:renderIf isTrue="{! v.showVersionButton }">
                        <lightning:button label="{! v.selectedVersionIsDraft ? 'Release version' : 'New Version' }" iconName="{! v.selectedVersionIsDraft ? 'utility:check' : 'utility:new' }" onclick="{! c.handleVersionButton }"/>
                    </aura:renderIf>
                </div>
            </div>                                  
        </div>
        <aura:renderIf isTrue="{! !(v.accessLevel == 0 &amp;&amp; v.bookRecord.SG_HistoryVersionNumber__c == 0) }">
            <div class="slds-col">
                <lightning:select name="select" label="Select a Version" value="{! v.selectedVersion }">
                    <aura:iteration items="{! v.versions }" var="ver">
                        <option text="{! ver.label }" value="{! ver.id }" selected="{! ver.selected }"/>
                    </aura:iteration>
                </lightning:select>
            </div>
        </aura:renderIf>
    </div> 
    <lightning:card>
        <c:SG_ProductComponent_Card bookRecord="{! v.bookRecord }"/> 
        <aura:iteration items="{! v.categories }" var="aCategory" >
            <c:SG_ProductComponent_Category category="{! aCategory.SG_ProductProperty__r.SG_Category__c }" productBookId="{! v.bookRecord.Id }" selectedVersion="{! v.selectedVersion }" lines="{! v.allLines }"/>
        </aura:iteration>
        <c:SG_ProductComponent_CalculatedFields productBookId="{! v.bookRecord.Id }" lines="{! v.allLines }"/>
    </lightning:card>
</div> 
</aura:component>
Controller:
({
/*
 *  Component initialization 
 *  Launches a different function depending on what type of page the component is displayed
 */
onInit : function(component, event, helper) {
    helper.getAccessLevel(component, event, helper);               
},

/*
 *  On selection of a version, requests the property values for said version
 */    
onChangeSelectedVersion : function(component, event, helper) {
    if(component.get('v.selectedVersion') != '' && component.get('v.bookRecord.Id') != null){      
        helper.setSelectedVersionStatus(component, event, helper);       
        helper.setShowButtons(component, event, helper); 
        helper.getProductPropertyValues(component, event, helper);       
    }       
}, 

/*
 *  Handles opening a new window previewing the product book as pdf
 */
handlePrint : function(component, event, helper) {        
    var url;
    if(component.get('v.communityName') != null) url = location.origin + '/' + component.get('v.communityName') + '/apex/SG_PrintBook?Id=' + component.get("v.bookRecord.Id") + '&version=' + component.get("v.selectedVersion");   
    else url = location.origin + '/apex/SG_PrintBook?Id=' + component.get("v.bookRecord.Id") + '&version=' + component.get("v.selectedVersion");         
    window.open(url, '', '');     
},    

/*
 *  Handles opening a modal for selecting the compare target
 */    
handleCompare : function(component, event, helper) {
    var modalBody;
    $A.createComponent("c:SG_ProductComponent_CompareModal", {"bookRecord": component.get("v.bookRecord"), "accessLevel": component.get("v.accessLevel")},
        function(content, status) {
            if (status === "SUCCESS") {
                modalBody = content;
                component.find('overlayLib').showCustomModal({
                    header: "Select a Product book to compare to",
                    body: modalBody, 
                    showCloseButton: true,
                    cssClass: "slds-modal_large"
                })
            }                               
        });
},

/*
 *  Handles opening a modal for selecting a new name for cloning
 */    
handleClone : function(component, event, helper) {
    var modalBody;
    $A.createComponent("c:SG_ProductComponent_Clone", {"bookRecord": component.get("v.bookRecord"), "accessLevel": component.get("v.accessLevel"), "version": component.get("v.selectedVersion")},
        function(content, status) {
            if (status === "SUCCESS") {
                modalBody = content;
                component.find('overlayLib').showCustomModal({
                    header: "Select a name for the new Product book",
                    body: modalBody, 
                    showCloseButton: true,
                    cssClass: "slds-modal_small"
                })
            }                               
        });
},

/*
 *  Handles opening a modal for editing values
 */    
handleEdit : function(component, event, helper) {
    var modalBody;
    $A.createComponent("c:SG_ProductComponent_EditModal", {"bookRecord": component.get("v.bookRecord"), "properties": component.get("v.allLines")},
        function(content, status) {
            if (status === "SUCCESS") {
                modalBody = content;
                component.find('overlayLib').showCustomModal({
                    header: "Edit "+component.get("v.bookRecord.Name"),
                    body: modalBody, 
                    showCloseButton: true,
                    cssClass: "slds-modal_large",
                    closeCallback: function() {
                       helper.getProductPropertyValues(component, event, helper);
                   }
                })
            }                               
        });
},
        
/*
 *  Handles operations to increment the release version number
 */      
handleVersionButton : function(component, event, helper) {
    if(component.get('v.selectedVersion') == component.get('v.bookRecord.SG_ReleaseVersionNumber__c')+1) helper.releaseVersion(component, event, helper);
    else helper.createNewVersion(component, event, helper);        
}, 
 
doAction : function(component, event, helper) {

    var accIdFromVf=component.get("v.bookRecord.Id");
    alert('Id of record from Vf page'+accIdFromVf);
} })

Please Advice.
Hi,

0
I was trying to create a New knowledge Article through Process builder, When a case status is set to validated.
As a part of creation We are referencing Case custom and standard fields to knowledge article custom and standard field.
I do have knowledge user permission in my user record.
But, still when I created case and set status to Validated it did not created the Article. I do checked for the required Knowledge fields and made sure they are populated on create new record process.
please advise what Iam missing here
Thanks,
 
We made a very minor change to the apex class where we included a field in the Email mathod in the class, however when we tried to deploy we get attempt to de-reference null object error.
Test class:
 
public static testMethod void testUpdateRegistration2(){

Course__c newCourse = new Course__c();
newCourse.Total_Sessions__c = 3;
newCourse.Session_No__c = 001;
newCourse.Registration_Time__c = '8:45AM';
newCourse.Number_of_Days__c = 1;
newCourse.Name = 'Apex Test Course';
newCourse.Minimum_Attendee__c = 5;
newCourse.Maximum_Attendee__c = 10;
newCourse.GST__c = 10;
newCourse.GST_Exempt_Course__c = false;
newCourse.Course_Type__c = 'Face to Face';
newCourse.Course_Start_Time__c = '9:00AM';
newCourse.Course_Number__c = 'C001';
newCourse.Course_End_Time__c = '5:00PM';
newCourse.Course_Classification__c = 'Public';
newCourse.ChargeID__c = 'PRC_999';
newCourse.Category__c = 'Food';
newCourse.Base_Price__c = 999;
insert newCourse;

datetime t = System.now();
date today = Date.newInstance(t.year(),t.month(),t.day());

Class__c newClass = new Class__c();
newClass.Name = 'Apex Test Class';
newClass.Minimim_Attendee__c = 9;
newClass.Maximum_Attendee__c = 99;
newClass.Course_Name__c = newCourse.Id;
newClass.Class_Location__c = 'Sydney';
newClass.Class_Begin_Date__c = today;
newClass.Class_End_Date__c = today;
newClass.Number_of_Confirmed_Attendees__c = 10;
newClass.Class_Status__c = 'Open';
insert newClass;

Account newAccount = new Account();
newAccount.Same_As_Address__c = 'true';
newAccount.Name = 'Apex Test';
//newAccount.ParentId = newAccountParent.Id;
newAccount.Mailing_Zip_Postal_Code__c = '2009'; 
newAccount.Mailing_Street__c = 'Fake Mailing Street';
newAccount.Mailing_State_Province__c = 'NSW';
newAccount.Mailing_Country__c = 'AUSTRALIA';
newAccount.Mailing_City__c = 'Sydney';
newAccount.CurrencyIsoCode = 'AUD';
newAccount.Business_Zip_Postal_Code__c = '1000'; 
newAccount.Business_Street__c = 'Fake Business Street';
newAccount.Business_State_Province__c = 'NSW';
newAccount.Business_Country__c = 'AUSTRALIA';
newAccount.Business_City__c = 'Sydney';
newAccount.Account_Classification__c = 'Business';
insert newAccount;

Account newVenueAccount = new Account();
newVenueAccount.Same_As_Address__c = 'true';
newVenueAccount.Name = 'Apex Venue Test';
newVenueAccount.Mailing_Zip_Postal_Code__c = '2009'; 
newVenueAccount.Mailing_Street__c = 'Fake Mailing Street';
newVenueAccount.Mailing_State_Province__c = 'NSW';
newVenueAccount.Mailing_Country__c = 'AUSTRALIA';
newVenueAccount.Mailing_City__c = 'Sydney';
newVenueAccount.CurrencyIsoCode = 'AUD';
newVenueAccount.Business_Zip_Postal_Code__c = '1000'; 
newVenueAccount.Business_Street__c = 'Fake Business Street';
newVenueAccount.Business_State_Province__c = 'NSW';
newVenueAccount.Business_Country__c = 'AUSTRALIA';
newVenueAccount.Business_City__c = 'Sydney';
newVenueAccount.Account_Classification__c = 'Business';
newVenueAccount.Type = 'Venue';
insert newVenueAccount;

Contact newContact = new Contact();
newContact.FirstName='John';
newContact.LastName='Doe';
newContact.Phone='0299998888';
newContact.Email = 'john.doe@fake.com';
newContact.AccountId = newAccount.Id;
newContact.Dietary_Requirements__c = 'ABC';
insert newContact;

Contact newContact1 = new Contact();
newContact1.LastName='Master';
newContact1.Email = 'a.master@fake.com';
newContact1.Phone = '0288889999';
newContact1.AccountId = newVenueAccount.Id;
insert newContact1;

Contact newContact2 = new Contact();
newContact2.Job_Title__c = 'National Manager';
newContact2.LastName='Master';
//newContact2.Email = 'a.master@fake.com';
newContact2.AccountId = newAccount.Id;
newContact2.MobilePhone = '0499999999';
insert newContact2;

Trainer_Approved_Course__c tac = new Trainer_Approved_Course__c();
tac.Name = 'Apex Trainer Approved Course';
tac.Trainer__c = newContact.Id;
tac.Expiration_Date__c = today + 100000;
tac.Course__c = newCourse.Id;
tac.Approved__c = true;
tac.CurrencyIsoCode = 'AUD';
insert tac;

Trainer_Approved_Course__c tac2 = new Trainer_Approved_Course__c();
tac2.Name = 'Apex Trainer Approved Course 2';
tac2.Trainer__c = newContact2.Id;
tac2.Expiration_Date__c = today + 100000;
tac2.Course__c = newCourse.Id;
tac2.Approved__c = true;
tac2.CurrencyIsoCode = 'AUD';
insert tac2;


Class__c newClass1 = new Class__c();
newClass1.Name = 'Apex Test Class';
newClass1.Minimim_Attendee__c = 9;
newClass1.Maximum_Attendee__c = 99;
newClass1.Course_Name__c = newCourse.Id;
newClass1.Class_Location__c = 'Sydney';
newClass1.Class_Begin_Date__c = today;
newClass1.Class_End_Date__c = today;
newClass1.Number_of_Confirmed_Attendees__c = 10;
newClass1.Class_Status__c = 'Open';
newClass1.Trainer_1__c = newContact.Id;
newClass1.Trainer_2__c = newContact1.Id;
newClass1.Venue__c = newVenueAccount.Id;
newClass1.Num_Material_Ordered__c = 10;
newClass1.Date_Material_Ordered__c = today;
newClass1.Num_in_Stock__c = 10;
newClass1.Num_Material_Printed__c = 5;
newClass1.Num_Standards_Out__c = 10;
newClass1.Num_Standards_In__c = 10;
newClass1.Boxes__c = 2;
newClass1.Job_Reference__c = 'N/A';
newClass1.Date_Material_Sent__c = today;
newClass1.Comments_Materials__c = 'N/A';
insert newClass1;

Id[] originalRegIds = new Id[0];
Registration__c newAttendee = new Registration__c();
newAttendee.Course_Name__c = newCourse.Id;
newAttendee.Attendee__c = newContact.Id;
newAttendee.Class_Name__c = newClass.Id;
newAttendee.Total_Amount__c = 999;
newAttendee.Status__c = 'Confirmed';
insert newAttendee;
originalRegIds.add(newAttendee.Id);

Registration__c newAttendee1 = new Registration__c();
newAttendee1.Course_Name__c = newCourse.Id;
newAttendee1.Attendee__c = newContact.Id;
insert newAttendee1;
originalRegIds.add(newAttendee1.Id);

Registration__c newAttendee2 = new Registration__c();
newAttendee2.Course_Name__c = newCourse.Id;
newAttendee2.Class_Name__c = newClass.Id;
newAttendee2.Attendee__c = newContact.Id;
newAttendee2.Status__c = 'Pended-SAI Cancellation';
insert newAttendee2;
originalRegIds.add(newAttendee2.Id);

Registration__c newAttendee3 = new Registration__c();
newAttendee3.Course_Name__c = newCourse.Id;
newAttendee3.Class_Name__c = newClass1.Id;
newAttendee3.Attendee__c = newContact1.Id;
newAttendee3.Status__c = 'Confirmed';
insert newAttendee3;

Registration__c newAttendee4 = new Registration__c();
newAttendee4.Course_Name__c = newCourse.Id;
newAttendee4.Class_Name__c = newClass1.Id;
newAttendee4.Attendee__c = newContact2.Id;
newAttendee4.Status__c = 'Confirmed';
insert newAttendee4;

Certificate_Template__c newCertificateTemplate = new Certificate_Template__c();
newCertificateTemplate.Name = 'Apex Test Certificate Template';
newCertificateTemplate.CurrencyIsoCode = 'AUD';
insert newCertificateTemplate;

Certificate_Type__c newCertificateType = new Certificate_Type__c();
newCertificateType.Name = 'Statement of Attendance';
newCertificateType.Course_Name__c = newCourse.Id;
newCertificateType.Certificate_Title__c = 'Statement of Attendance';
newCertificateType.Certificate_Template__c = newCertificateTemplate.Id;
newCertificateType.Certificate_Options__c = 'Always Issued';
insert newCertificateType;

// reset governor limit
Test.startTest();

Assessment__c newAssessment = new Assessment__c();
newAssessment.Name = 'Statement of Attendance';
newAssessment.Assessment_Title__c = newCertificateType.Id;
newAssessment.Assessment_Status__c = 'Competent';
newAssessment.Attendee_ID__c = newAttendee.Id;
newAssessment.Assessor__c = newContact.Id;
newAssessment.Received_from_Assessor__c = today;
insert newAssessment;

Assessment_Competency__c newAssessmentCompetency = new Assessment_Competency__c();
newAssessmentCompetency.Name = 'Apex Test Assessment Competency';
newAssessmentCompetency.CurrencyIsoCode = 'AUD';
newAssessmentCompetency.Competency_Code__c = 'ApexTest_9999';
newAssessmentCompetency.Assessment__c = newAssessment.Id;
insert newAssessmentCompetency;

Invoice_ENT__c newInvoiceENT = new Invoice_ENT__c();
newInvoiceENT.Registration__c = newAttendee.Id;
newInvoiceENT.CurrencyIsoCode = 'AUD';
newInvoiceENT.Base_Price__c = 998;
newInvoiceENT.Payment_Status__c = 'c';
newInvoiceENT.Invoice_Type__c = 'ACR';
newInvoiceENT.Bill_Type__c = 'EAR';
insert newInvoiceENT;

Invoice_ENT__c newInvoiceENT1 = new Invoice_ENT__c();
newInvoiceENT1.Registration__c = newAttendee.Id;
newInvoiceENT1.CurrencyIsoCode = 'AUD';
newInvoiceENT1.Base_Price__c = 998;
newInvoiceENT1.Payment_Status__c = 'c';
newInvoiceENT1.Invoice_Type__c = 'REG';
newInvoiceENT1.Bill_Type__c = 'PUB';
insert newInvoiceENT1;

 try{
    Integer processType = 1;
    ClassObj.classcancellation(newClass.Id, processType);
    ClassObj.sendAttendanceList(newClass1.Id);
    ClassObj.sendAttendanceList_TIS(newClass1.Id);
    //System.assertEquals(0, classObj.checkPendingRegos(newClass.Id));
} catch (System.EmailException e){
    System.debug('we caught a email exception: ' + e.getDmlMessage(0));
}

Test.stopTest();
From the above code bold syntax is the line number 1071

Please find the image below of the error I get during deployment.
User-added image
Class:
 
WebService static Id[] sendAttendanceList_TIS(Id ClassId) {

//Modified by sneh@sqwarepeg.com to include more venue and class material details
Class__c classObj = [Select Trainer_1__c, Trainer_1__r.Id, Trainer_1__r.Email,Trainer_1__r.EmailBouncedDate, 
Trainer_1__r.EmailBouncedReason,Trainer2__c, Trainer2__r.Id, Trainer2__r.Email, Trainer2__r.EmailBouncedDate, 
Trainer2__r.EmailBouncedReason, Trainer_2__c, Trainer_2__r.Id, Trainer_2__r.EmailBouncedDate, 
Trainer_2__r.EmailBouncedReason,Trainer_2__r.Email, Id, Venue__r.Id, Venue__r.Name, Venue__r.Business_Street__c, 
Venue__r.Business_City__c, Venue__r.Business_State_Province__c, Venue__r.Business_Zip_Postal_Code__c, 
Venue__r.Business_Country__c, Venue__r.Website, Venue__r.Phone, Venue__r.Internet_Email__c, Venue__r.Comments__c, 
Course_Name__r.Name, Class_Location__c, Class_End_Date__c, Class_Begin_Date__c, Num_in_Stock__c, 
Num_Standards_Out__c, Num_Standards_In__c, Num_Material_Printed__c, Num_Material_Ordered__c, Job_Reference__c, 
Date_Material_Sent__c, Date_Material_Ordered__c, Comments_Materials__c, Boxes__c 
From Class__c where Id =:ClassId];

//Modified by suzan@sqwarepeg.com, validation of the bounced emails
//Modified by sneh@sqwarepeg.com on 12/02/2009 to incorporate the Primary_Venue_Contact__c functionality
Contact[] conObj = [Select Id, Email, AccountId,EmailBouncedDate,EmailBouncedReason From Contact where AccountId =:classObj.Venue__r.Id and Primary_Venue_Contact__c = true];

//Contact[] conObj = [Select Id, Email, AccountId From Contact where AccountId =:classObj.Venue__r.Id];
//Query course field to add them in the Email template.
Course__c crs = [select id,Current_Revision__c from Course__c limit 1];
//if (classObj.Trainer_1__r.Email != null || classObj.Trainer_2__r.Email != null || conObj.Email != null) {
String jobTitle;
String email;
String phone;
String mobile;
String dietaryNeeds;
String accessNeeds;
String HTMLBody;

List<Id> RegIds = new List<Id>();
RegIds = getConfirmedIds(ClassId);

HTMLBody = 'Hi,<br><br>';
HTMLBody = HTMLBody + 'Please find attached the Attendance List for SAI Global\'s course.<br><br>';
HTMLBody = HTMLBody + 'Please print off a copy and hand to the Trainer on the morning of the course.<br><br>';
HTMLBody = HTMLBody + 'If you have any questions please don\'t hesitate to contact our Customer Service Team on 1-800-374-3818.<br><br>';
HTMLBody = HTMLBody + 'Kind Regards,<br>Training and Improvement Solutions<br><br>';
HTMLBody = HTMLBody + '<b><u>Course Information</u></b><br><br>';
if(classObj.Class_End_Date__c != null){
    HTMLBody = HTMLBody + 'Course Name: ' + classObj.Course_Name__r.Name + '<br>' + 'Current Revision:' + crs.Current_Revision__c.format() + '<br>' + 'Class Dates: ' + classObj.Class_Begin_Date__c.day() + '/' + classObj.Class_Begin_Date__c.month() + '/' + classObj.Class_Begin_Date__c.year() + ' - ' + classObj.Class_End_Date__c.day() + '/' + classObj.Class_End_Date__c.month() + '/' + classObj.Class_End_Date__c.year() + '<br>';
} else {
    HTMLBody = HTMLBody + 'Course Name: ' + classObj.Course_Name__r.Name + '<br>' + 'Current Revision:' + crs.Current_Revision__c.format() + '<br>' + 'Class Dates: ' + classObj.Class_Begin_Date__c.day() + '/' + classObj.Class_Begin_Date__c.month() + '/' + classObj.Class_Begin_Date__c.year() + ' - N/A<br>';
}
HTMLBody = HTMLBody + 'Class Location: ' + classObj.Class_Location__c + '<br><br>';

From the above code, The bold Syntax is line 429.

Please advise.

Thanks