• Jay Wang 2
  • NEWBIE
  • 20 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 2
    Questions
  • 10
    Replies
Hi,

I'm using a lightning component that uses lightning:map and it contains multiple markers, code from: 
https://developer.salesforce.com/docs/component-library/bundle/lightning:map/example#lightningcomponentdemo:exampleMapMultipleMarkers 

User-added image

Now I was just wondering if anyone knew how to add a link to the google maps directions in the information of the markers. For example something similar to below except I only care about the directions link.

User-added image

Thanks for your time and any help would be appreciated,

Jay
Hello,

I am trying to do a check on a User to see if they have verified their Email/Mobile and I can see that the User object has this field, however I cannot seem to find a way to access it with apex/VF. Any help would be appreciated. I have attached a picture below showing the flag in the list view in Users.

User-added image

Kind Regards,

Jay
Hey guys, I have a simple trigger before change:
 
trigger AssemblyDiaryEditValidation on Assembly_diary__c (before update) {
    Set<Id> aids = new Set<Id>();
	Set<Id> saids = new Set<Id>();
    Set<Id> sraids = new Set<Id>();
    for(Assembly_diary__c a :trigger.old) {
        aids.add(a.Id);
        saids.add(a.Service_Appointment__c);
    }
    ServiceAppointment[] sa = [Select Id From ServiceAppointment where Id in :saids];
    AssignedResource[] ar = [Select Id, ServiceResourceId From AssignedResource where ServiceAppointmentId in :saids];
    if(ar != null) {
        sraids.add(ar[0].ServiceResourceId);
    }
    ServiceResource[] sr = [Select Id, RelatedRecordId From ServiceResource where Id in :sraids]; 
    for (Assembly_diary__c b :trigger.old) {
    for(integer i = 0; i < Trigger.new.size(); i++) {
        if(sr != null) {
            if(sr[0].RelatedRecordId != UserInfo.getUserId()) {
                b.addError('Nejste oprávněni upravit tuto položku');
            }
        }
    }
    }
}

I get the error message SObject row does nto allow errors on line 19. I know that you can use the addError method for only those records that are avaliable in Trigger Context. But I thought i fixed it? How do I fix this?
I'm trying to update a field on the account when a child record is deleted but the field isn't updating. Here's the trigger:
trigger RatePlanDeletion on Zuora__SubscriptionRatePlan__c (after delete) {

	// Make a list of the deleted subscription rate plans
	List<Zuora__SubscriptionRatePlan__c> deletedRatePlan = [SELECT Id,
Name,
Zuora__Account__r.Local_Listings__c,
Zuora__Account__r.Engage__c,
Zuora__Account__r.SEO__c,
Zuora__Account__r.Social_Ads__c,
Zuora__Account__r.Social_Posting__c,
Zuora__Account__r.Website_Product__c
Zuora__SubscriptionRatePlan__c
IN :Trigger.old];

	List<Zuora__SubscriptionRatePlan__c> newRatePlan = new List<Zuora__SubscriptionRatePlan__c>();

	for (Zuora__SubscriptionRatePlan__c sub : deletedRatePlan) {

		// Get Trigger.new version of the rate plan
		Zuora__SubscriptionRatePlan__c subInTriggerNew = Trigger.newMap.get(sub.Id);		
		
		// Local Listings
		if ((sub.Name.contains('Marketing Essentials') || sub.Name.contains('Local Listings'))) {
			subInTriggerNew.Zuora__Account__r.Local_Listings__c = false;
		}

		// Engage 
		if (sub.Name.contains('Engage')) {
			subInTriggerNew.Zuora__Account__r.Engage__c = false;
		}

		// Reviews
		if (sub.Name.contains('Review')) {
			subInTriggerNew.Zuora__Account__r.Reviews__c = false;
		}

		// SEO
		if (sub.Name.contains('SEO')) {
			subInTriggerNew.Zuora__Account__r.SEO__c = false;
		}

		// Social Ads
		if (sub.Name.contains('Social Ads')) {
			subInTriggerNew.Zuora__Account__r.Social_Ads__c = false;
		}

		// Social Posting
		if (sub.Name.contains('Social Posting')) {
			subInTriggerNew.Zuora__Account__r.Social_Posting__c = false;
		}

		// Website
		if (sub.Name.contains('Website')) {
			subInTriggerNew.Zuora__Account__r.Website_Product__c = false;
		}
		
		newRatePlan.add(subInTriggerNew);
	}
	update newRatePlan;
}
I appreciate any help I can get.
I am hitting the wall on this test class.  The Trigger and code are below.  Any suggestions are welcome.  It's my first try at a test class.  When running the test, my query does not seam to fire.  However, when I run it in the query editor, it pulls the correct account.  Also, none of my system.debugs show in logs when filtering for "Debug Only"

In the logs I get: "FATAL_ERROR System.QueryException: List has no rows for assignment to SObject."
 
trigger UpdateDisReg on Account (after update) {

        Account a = Trigger.New[0];
        String alias = 'a.center__c';
        System.debug(a);
        List<Lead> leadsToUpdate = [select id,CenterDistrict__c,CenterRegion__c from Lead where Owner_Alias__c = 'alias'];

        System.debug(leadsToUpdate);
        List<Lead> leads = new List<Lead>();
        
    for(Lead Leadz : leadsToUpdate) {
         leadz.CenterDistrict__c = a.District__c;
         leads.add(leadz);
         {
       
       update leads;
}
}
}
Test Class:
 
@isTest
private class UpdateDisRegTest {
        private static testMethod void UpdateDisReg() {
        
        Account a = [SELECT Id, District__c, Region__c FROM Account WHERE NAME IN ('Center 000001')];
        insert a;
        System.Debug(a);
            
            
        Lead l = [SELECT Id, CenterDistrict__c, CenterRegion__c FROM Lead WHERE Owner_Alias__c = '000001' Limit 1];
        insert l;
    	System.Debug(l);
            
        Test.startTest();
        
        a.District__c = 55;
        a.Region__c = 66;
            
        update a;
       
		System.assertEquals(55, l.CenterDistrict__C);  
        System.assertEquals(66, l.CenterDistrict__C);
            
        Test.stopTest();
  
   }
  
}


 
Dear all,
May i know if I can convert lead to only an existing account. the conversion will read based on company name in lead module. the apex now will create all new account, opportunty and contact ;

what i have done is creating a process builder that will run this apex when a lead becomes hot.



Public class AutoConvertLeads
{
    @InvocableMethod
    public static void LeadAssign(List<Id> LeadIds)
    {
        LeadStatus CLeadStatus= [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true Limit 1];
        List<Database.LeadConvert> MassLeadconvert = new List<Database.LeadConvert>();
        for(id currentlead: LeadIds){
                Database.LeadConvert Leadconvert = new Database.LeadConvert();
                Leadconvert.setLeadId(currentlead);                
                Leadconvert.setConvertedStatus(CLeadStatus.MasterLabel);
               // Leadconvert.setDoNotCreateOpportunity(TRUE); Remove this line if you want to create an opportunity from Lead Conversion 
                MassLeadconvert.add(Leadconvert);
        }
        
        if (!MassLeadconvert.isEmpty()) {
            List<Database.LeadConvertResult> lcr = Database.convertLead(MassLeadconvert);
        }
    }
}
Below is the method which is throwing "Attempt to de-reference a null object, 3332".Can somebody help?
it is called under Before insert and  Update
----------------------------------------------------------------------------------------------------
if(Trigger.isBefore){
        if(Trigger.isInsert)
            R2_CLS_CaseTriggerMethods.checkStatusCountAndDate(news, null);
-------------------------------------------------------------------------------------------------------------------------
if(Trigger.isUpdate)
            R2_CLS_CaseTriggerMethods.checkStatusCountAndDate(news, olds);
------------------------------------------------------------------------------------------------------------------------
public static void checkStatusCountAndDate(List<Case> news, List<Case> olds){
        try{
            if(R1_CLS_LogHelper.isRunningTest()){throw new R1_CLS_LogHelper.R1_Exception('test');} 

            Id rtIdExp = Schema.SObjectType.Case.getRecordTypeInfosByName().get('Expediente').getRecordTypeId();
            Id rtIdCons = Schema.SObjectType.Case.getRecordTypeInfosByName().get('Consulta').getRecordTypeId();
            Id rtIdGDPR = Schema.SObjectType.Case.getRecordTypeInfosByName().get('GDPR').getRecordTypeId();

            //fill the set with the possible status to close a transction
            Set<String> statusEndTransactionSet = new Set<String>();
            statusEndTransactionSet.add('Closed');
            statusEndTransactionSet.add('Cancelled');
            statusEndTransactionSet.add('Waiting on Iberia');
            statusEndTransactionSet.add('Waiting on Cliente');

            for (Integer i = 0; i < news.size(); i++) {
                if (news[i].RecordTypeId == rtIdExp || news[i].RecordTypeId == rtIdCons || news[i].RecordTypeId == rtIdGDPR) {
                    //is insert
                    if (olds == null) {
                        //check if the status corresponding to a close transaction
                        if (statusEndTransactionSet.contains(news[i].Status)) {
                            news[i].R2_CAS_DAT_First_Transaction_date__c = System.Today();
                            news[i].R2_CAS_NUM_Count_Number_Transaction__c = 1;
                        }
                        else if (news[i].Status == 'Reabierto') {
                            news[i].R2_CAS_NUM_Count_Number_Reopen__c = 1;
                            news[i].R2_CAS_DAT_First_Reopen_Date__c = System.Today();
                            news[i].R2_CAS_DAT_Last_Reopen_Date__c = System.Today();
                        }
                    }
                    // is update
                    else {
                        if (!statusEndTransactionSet.contains(olds[i].Status) && statusEndTransactionSet.contains(news[i].Status)) {
                            news[i].R2_CAS_NUM_Count_Number_Transaction__c = olds[i].R2_CAS_NUM_Count_Number_Transaction__c + 1;
                            if (olds[i].R2_CAS_DAT_First_Transaction_date__c == null) {
                                news[i].R2_CAS_DAT_First_Transaction_date__c = System.Today();
                            }
                        }
                        else if (olds[i].Status != news[i].Status && statusEndTransactionSet.contains(olds[i].Status) && news[i].Status == 'Reabierto') {
                            news[i].R2_CAS_NUM_Count_Number_Reopen__c = olds[i].R2_CAS_NUM_Count_Number_Reopen__c + 1;
                            news[i].R2_CAS_DAT_Last_Reopen_Date__c = System.Today();
                            if (olds[i].R2_CAS_DAT_First_Reopen_Date__c == null) {
                                news[i].R2_CAS_DAT_First_Reopen_Date__c = System.Today();
                            }
                            if (olds[i].R2_CAS_DAT_Last_Reopen_Date__c != null) {
                                news[i].R2_CAS_DAT_Penultimate_Reopen_Date__c = olds[i].R2_CAS_DAT_Last_Reopen_Date__c;
                            }
                        }
                    }
                }
            }
        }catch(Exception exc){
            R1_CLS_LogHelper.generateErrorLog('R2_CLS_CaseTriggerMethods.checkStatusCountAndDate()', '', exc.getmessage()+', '+exc.getLineNumber(), 'Case');
        }
    }
Hello,

I am trying to do a check on a User to see if they have verified their Email/Mobile and I can see that the User object has this field, however I cannot seem to find a way to access it with apex/VF. Any help would be appreciated. I have attached a picture below showing the flag in the list view in Users.

User-added image

Kind Regards,

Jay
HI All,

I want to sort the column in lightning datatable. All other columns are getting sorted properly except Account Name

<aura:component controller="AccountListController"
                 implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    Component
    <aura:attribute type="Account[]" name="acctList"/>
    <aura:attribute name="mycolumns" type="List"/>
    <aura:attribute name="sortedBy" type="String" default="Name"/>
    <aura:attribute name="sortedDirection" type="String" default="asc"/>
    
    <aura:handler name="init" value="{!this}" action="{!c.fetchAccounts}"/>
    
    <lightning:datatable data="{!v.acctList}" 
                         columns="{!v.mycolumns}" 
                         keyField="id"
                         hideCheckboxColumn="true"
                         onsort="{!c.updateColumnSorting}"
                         sortedBy="{!v.sortedBy}"  
                         sortedDirection="{!v.sortedDirection}"/>
    
</aura:component>

CONTROLLER.JS

({
    fetchAccounts : function(component, event, helper) {
        component.set('v.mycolumns', [
            {label: 'Account Name', fieldName: 'accUrl__c', type: 'url', sortable: true,typeAttributes: {label: { fieldName: 'Name' }, target: '_blank',sortable:'true'}},
            {label: 'Industry', fieldName: 'Industry', type: 'text'},
            {label: 'Type', fieldName: 'Type', type: 'Text'}
        ]);
        var action = component.get("c.fetchAccts");
        action.setParams({
        });
        action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                component.set("v.acctList", response.getReturnValue());
                helper.sortData(component, component.get("v.sortedBy"), component.get("v.sortedDirection"));
            }
        });
        $A.enqueueAction(action);
    },
    updateColumnSorting: function (cmp, event, helper) {
        var fieldName = event.getParam('fieldName');
        if (fieldName == 'accUrl__c'){fieldName = 'Name';}
        alert('fieldName >> '+fieldName);
        var sortDirection = event.getParam('sortDirection');
        alert('sortDirection >> '+sortDirection);
        cmp.set("v.sortedBy", fieldName);
        cmp.set("v.sortedDirection", sortDirection);
        helper.sortData(cmp, fieldName, sortDirection);
    }
})

Helper.Js

({
    sortData: function (cmp, fieldName, sortDirection) {
        var data = cmp.get("v.acctList");
        var reverse = sortDirection !== 'asc';
        data.sort(this.sortBy(fieldName, reverse))
        cmp.set("v.acctList", data);
    },
    
    sortBy: function (field, reverse, primer) {
        var key = primer ?
            function(x) {return primer(x.hasOwnProperty(field) ? (typeof x[field] === 'string' ? x[field].toLowerCase() : x[field]) : 'aaa')} :
            function(x) {return x.hasOwnProperty(field) ? (typeof x[field] === 'string' ? x[field].toLowerCase() : x[field]) : 'aaa'};
       alert('direction2 >> '+reverse);
        alert('direction3 >> '+reverse);
        reverse = !reverse ? 1 : -1;
       alert('direction4 >> '+reverse);
        return function (a, b) {            
           // return a = key(a), b = key(b), reverse * ((a > b) - (b > a));
           return a = key(a)?key(a):'', b = key(b)?key(b):'', reverse * ((a > b) - (b > a));
        }
    }
})

Apex Class:
public class AccountListController {

    @AuraEnabled
    public static List < Account > fetchAccts() {
        return [ SELECT Id, Name, Industry, Type,accUrl__c FROM Account  ];
    }
    
}​

accUrl__c ​ is a formula field on Account with return type text : "https://toons-dev-ed.lightning.force.com/one/one.app#/sObject/" &Id& "/view" 
HI All,

I want to sort the column in lightning datatable. All other columns are getting sorted properly except Account Name

<aura:component controller="AccountListController"
                 implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    Component
    <aura:attribute type="Account[]" name="acctList"/>
    <aura:attribute name="mycolumns" type="List"/>
    <aura:attribute name="sortedBy" type="String" default="Name"/>
    <aura:attribute name="sortedDirection" type="String" default="asc"/>
    
    <aura:handler name="init" value="{!this}" action="{!c.fetchAccounts}"/>
    
    <lightning:datatable data="{!v.acctList}" 
                         columns="{!v.mycolumns}" 
                         keyField="id"
                         hideCheckboxColumn="true"
                         onsort="{!c.updateColumnSorting}"
                         sortedBy="{!v.sortedBy}"  
                         sortedDirection="{!v.sortedDirection}"/>
    
</aura:component>

CONTROLLER.JS

({
    fetchAccounts : function(component, event, helper) {
        component.set('v.mycolumns', [
            {label: 'Account Name', fieldName: 'accUrl__c', type: 'url', sortable: true,typeAttributes: {label: { fieldName: 'Name' }, target: '_blank',sortable:'true'}},
            {label: 'Industry', fieldName: 'Industry', type: 'text'},
            {label: 'Type', fieldName: 'Type', type: 'Text'}
        ]);
        var action = component.get("c.fetchAccts");
        action.setParams({
        });
        action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                component.set("v.acctList", response.getReturnValue());
                helper.sortData(component, component.get("v.sortedBy"), component.get("v.sortedDirection"));
            }
        });
        $A.enqueueAction(action);
    },
    updateColumnSorting: function (cmp, event, helper) {
        var fieldName = event.getParam('fieldName');
        if (fieldName == 'accUrl__c'){fieldName = 'Name';}
        alert('fieldName >> '+fieldName);
        var sortDirection = event.getParam('sortDirection');
        alert('sortDirection >> '+sortDirection);
        cmp.set("v.sortedBy", fieldName);
        cmp.set("v.sortedDirection", sortDirection);
        helper.sortData(cmp, fieldName, sortDirection);
    }
})

Helper.Js

({
    sortData: function (cmp, fieldName, sortDirection) {
        var data = cmp.get("v.acctList");
        var reverse = sortDirection !== 'asc';
        data.sort(this.sortBy(fieldName, reverse))
        cmp.set("v.acctList", data);
    },
    
    sortBy: function (field, reverse, primer) {
        var key = primer ?
            function(x) {return primer(x.hasOwnProperty(field) ? (typeof x[field] === 'string' ? x[field].toLowerCase() : x[field]) : 'aaa')} :
            function(x) {return x.hasOwnProperty(field) ? (typeof x[field] === 'string' ? x[field].toLowerCase() : x[field]) : 'aaa'};
       alert('direction2 >> '+reverse);
        alert('direction3 >> '+reverse);
        reverse = !reverse ? 1 : -1;
       alert('direction4 >> '+reverse);
        return function (a, b) {            
           // return a = key(a), b = key(b), reverse * ((a > b) - (b > a));
           return a = key(a)?key(a):'', b = key(b)?key(b):'', reverse * ((a > b) - (b > a));
        }
    }
})

Apex Class:
public class AccountListController {

    @AuraEnabled
    public static List < Account > fetchAccts() {
        return [ SELECT Id, Name, Industry, Type,accUrl__c FROM Account  ];
    }
    
}​

accUrl__c ​ is a formula field on Account with return type text : "https://toons-dev-ed.lightning.force.com/one/one.app#/sObject/" &Id& "/view"