• Abdul Khatri
  • PRO
  • 4239 Points
  • Member since 2015

  • Chatter
    Feed
  • 136
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 1180
    Replies

Hi All,

 

string templateId = '00XN0000002LbV8MAK';
string domainUrl = URL.getSalesforceBaseUrl().toExternalForm();
HttpRequest req = new HttpRequest();
req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());
req.setHeader('Content-Type', 'application/json');
req.setEndpoint(domainUrl+'/services/data/v51.0/tooling/query/?q=select+id,SenderType,templateId+from+WorkflowAlert+where+templateId=\''+templateId+'\'');
req.setMethod('GET'); 
Http h = new Http();
HttpResponse res = h.send(req);
system.debug(res.getBody());
Map<String, Object> deserialized = (Map<String, Object>)JSON.deserializeUntyped(res.getBody());
Object data1 = deserialized.get('records');
System.debug(deserialized.get('records'));
System.debug(deserialized.get('size'));

 

res.getBody(); -> {"size":1,"totalSize":1,"done":true,"queryLocator":null,"entityTypeName":"WorkflowAlert","records":[{"attributes":{"type":"WorkflowAlert","url":"/services/data/v51.0/tooling/sobjects/WorkflowAlert/01WN00000005esGMAQ"},"Id":"01WN00000005esGMAQ","SenderType":"CurrentUser","TemplateId":"00XN0000002LbV8MAK"}]}

 

Im trying to get ,"SenderType":"CurrentUser"  value but values is not returning: 

System.debug(deserialized.get('records')); --> [{"TemplateId":"00XN0000002LbV8MAK","SenderType":"CurrentUser","Id":"01WN00000005esGMAQ","attributes":{"url":"/services/data/v51.0/tooling/sobjects/WorkflowAlert/01WN00000005esGMAQ","type":"WorkflowAlert"}}]

 

How to get SenderType Value?

 

Thanks in Advance,

Hi Everyone,

problem statement: 
I am passing a SOQL query through a textArea of my Visualforce page. I want my controller to split the query and get a list of the queried coloums:

For ex. : InputQuery : 'Select Id, Name, Rating from Account' or 
'Select Id,Name,Rating from Account'(without space in fields)

Output result : List<String>= ['id', 'Name','Rating'];

I tried with InputQuery.split(' ') method but unable to get desired result. Please help me with this.
Hi,
I have written following apex class and test class. I'm getting an error saying "List has no rows for assignment to SObject" and my test class is getting failed though my code coverage is 91%. I'd appreciate any assistance.



public  class MMAResultReportController

{
    public List<DOAS_AVS_RESPONSE_LEVEL_1__c> avsresults {get;set;}
    public Test_MMA2__c avsRequest {get;set;}
    public string strRequestID{get;set;}
    
    //public string searchRef{get;set;}
    public  MMAResultReportController(){
        system.debug('####Printing page reference');
        system.debug(System.currentPageReference().getParameters().get('RequestID'));
        strRequestID=System.currentPageReference().getParameters().get('RequestID');
        
        getavsRequest();
    }
    public void getavsRequest(){
        avsRequest= new Test_MMA2__c();
        //system.debug ('####strRequestID is: '+strRequestID);
        //system.debug('####Variable is: ' + strRequestID);
        avsRequest = [select MMA_Request_ID__c,MMA_RecordType__c,MMA_Suffix__c,MMA_DOB__c,MMA_Middle_Name__c,MMA_Flag__c,MMA_Sex__c,MMA_SSN__c,MMA_First_Name__c, MMA_Last_Name__c, MMA_Family_ID__c, MMAReportDate__c,MMA_BENE_SSN1__c,
from Test_MMA2__c where MMA_Request_ID__c =:strRequestID];//                                                                 
    }
    
           
    
}


Test Class-

@isTest(SeeAllData=true)
public class MMAResultReportController_Test {
    @istest static void test(){

        Test_MMA2__c tes= new Test_MMA2__c ();
        tes.name='Sample';
        tes.MMA_First_Name__c='John';
        tes.MMA_Last_Name__c='Smith';
        tes.MMAReportDate__c=date.today();
        tes.MMA_Middle_Name__c='De';
       
        insert tes;
        test.startTest();
     
       MMAResultReportController ce= new MMAResultReportController();
      
        ce.getavsRequest();
        test.stopTest();
    }

 
I have two custom objecrt 1. stock_register__c 2. stock_regirser_line__c
i have master detail relation field quantity__c with stock_register__c(parent object) and  stock_regirser_line__c (chield)

I need to write a before insert and before update trigger to restrict the  sum of quantiy__in stock_regirser_line__c can not be more that  allocated_quanity__c in the parent object(stock_register__c)

Please help!!
thanks in advance!!
I'm trying to write an SOQL query that will pull information from the Contact object and the Event Object.  When I tried to use Event as the child object, I received an error message that Event could not be the child, so I switched the query around to this:
SELECT Event.whoid, Event.StartDateTime, Event.Subject, (select contact.id, contact.firstname, contact.lastname, contact.MailingStreet, contact.MailingCity, contact.MailingState, contact.MailingPostalCode from Contact)
from Event
Where Event.whoid = '0034M000020OgliQAC'

Unfortunately, it still isn't working.  It tells me "Didn't understand relationship 'Contact' in FROM part of query call.".  What am I doing wrong?

In SQL, the query would look like this:
Select Event.Whoid, Event.StartDateTime, Event.Subject, Contact.firstname, contact.lastname, contact.MailingStreet, Contact.MailingCity, contact.MailingState, contact.MailingPostalCode
from Event
Join Contact on Event.Whoid = Contact.id
where event.whoid = '0034M000020OgliQAC'

Any assistance would be greatly appreciated.
Hi All,
I am trying to cover wrapper class in calss. But it s not covering. I am sharing my class and test class.

Apex class
public class accountCController {
    @AuraEnabled (cacheable=true)
    public static List<accWrapper> getNameValues(List<string> acname){
        List<accWrapper> resultObject = new List<accWrapper>();
        string query = 'SELECT Id,Name FROM account  WHERE  Name';
        query+='=: acname';
        List<SObject> lstResult = Database.query(query);
        for (SObject res : lstResult) {
            accWrapper obj = new accWrapper();
            obj.testId = (String)res.get('Id');
            obj.testName = (String)res.get('Name');
            resultObject.add(obj);
        }       
        return resultObject;
    }
    public class accWrapper{
        @AuraEnabled
        public String testId;
        @AuraEnabled
        public String testName;
    }
	}

Test class:
@isTest
public class accountController_Test {
    static testMethod void testName(){  
        List<string> strList = new List<string>();
        strList.add('A');
        strList.add('B');
        accountCController.getNameValues(strList);
       
    }
}


Its covering "getNameValues" method but it is not covering wrapper class. Please help me on this.​​​​​​​

Thanks in advance

Regards,
​​​​​​​Ramana

trigger countTack on MyTask__c (after update) {
   List<MyTask__c> myTask = [SELECT Id,(SELECT Id,CountMyTask__с FROM Contact) FROM MyTask__c WHERE Id IN :Trigger.New];
   for(MyTask__c my :myTask){
      List<Contact> contactList = my.Contacts;
      my.CountMyTask__c = contactList.size();
   }
}
Dont work

Hi,
Iam new to apex. this is one of the trigger scenario bothering me.
Please help me with this.

I have a status checkbox field on accounts.
status picklist field with "open","closed" on contacts.
1) if status="closed" in all the related contacts then checkbox on account should be true.
2) if status="open" in any one of the related contacts then checkbox on account should be false.  
-------------------------------------------------------------------------------------------
Trigger:
trigger contactTrigg on contact(after insert, after update, after delete, after undelete){
    if(trigger.isInsert || trigger.isUpdate){
        accProgress.method1(trigger.new,trigger.old);
    }
}

-------
Handler:
public class accProgress{
    public static void method1(list<contact> newInsert, list<contact> oldInsert){
        
        set<id> conSet = new set<id>();
        
        for(contact con1 : newInsert){
            if(con1.Accountid != null){
                conSet.add(con1.accountid);
            }
        }
 for(contact con2 : oldInsert){
                conSet.add(con2.accountid);
        }

        List<account> accList =[SELECT id, progress_field__c,(SELECT id, progress_field_contacts__c FROM contacts) FROM account WHERE id IN :conSet];
        if(accList != null){
            for(account acc : accList){
                for(contact con : acc.contacts){
                    
                    if(con.progress_field_contacts__c == 'open' ){
                        acc.progress_field__c = false;
                    }
                    else{
                        acc.progress_field__c = true;
                    }
                }
            }
            update accList;
        }
    }
---------------------------------------------------------------------------------------------
1st one is working. i.e, whenever i make all related contacts "close" . the check box is getting checked(true).
2nd one is where iam failing. when i'm changing any contacts picklist values to open the account status checkbox is not unchecking(false).
please help me.
  • December 20, 2020
  • Like
  • 0

Need a query that basically says

(ExposeCase = true OR CreatedByID = UserInfo.getUserId()) AND isClosed = false

which would be in the following syntax and sort of a combination of these:

soql += ' Where CreatedById = \'' + UserInfo.getUserId() + '\' OR Expose_Case__c = true';

soql += ' Where Expose_Case__c = true AND isClosed = false';

I am unable to figure out the syntax. I've tried the following 

soql += ' Where CreatedById = \'' + UserInfo.getUserId() + '\' OR Expose_Case__c = true' + 'AND isClosed = false';

Hi,

I need to to change below code and use Database.insert() to insert records, iterate over the results, and persist information about any failures to the database ...reason to do above is I want to report Records in Batchable Salesforce apex code such that it should report where the Level2 or Level3 are NULL..Can some one edit the below Batch apex code to use Database.insert() to insert records, iterate over the results, and persist information about any failures to the database

here is current code
global class ertcopybatch3pm implements Database.Batchable<sObject> {
              
                global Database.QueryLocator start(Database.BatchableContext BC) {
                    // collect the batches of records or objects to be passed to execute
                    
                    String query = 'select Case__c, Level_1__c, Level_2__c,Level_3__c  FROM ERT_Case_Type__c';
                    System.debug('ERT Case No is =====>' +query);
                    return Database.getQueryLocator(query);
                }
                
                global void execute(Database.BatchableContext BC, List<ERT_Case_Type__c> exeList) {
                   
                    // process each batch of records
            List<Case_Type__c> listCTD = new List<Case_Type__c>();
                    System.debug('ERT Case No is =====>' +exeList);
                    for(ERT_Case_Type__c exe : exeList)
                    {        
                         listCTD.add(new Case_Type__c(Case__c=exe.Case__c,Level_1__c=exe.Level_1__c,Level_2__c=exe.Level_2__c,Level_3__c=exe.Level_3__c));
                       // System.debug('ERT Case No is =====>' +Case__c);
                    }
                    try {
                      System.debug('ERT Case No is =====>' +listCTD);
                        insert listCTD;
                    
                    } catch(Exception e) {
                        System.debug(e);
                    }
                    
                }   
                
                global void finish(Database.BatchableContext BC) {
                  // execute any post-processing operations
              }
            }

Your help is highly appreciated

Regards.
Fiona

Hi ,

I am new to Salesforce development, and I am doing my first project on integrating Salesforce and external systems. My remote system will use the REST API to create/update/delete data in Salesforce. I read the following in the Salesforce document :

"Error handling—All the remote call-in methods, standard or custom APIs, require the remote system to handle any subsequent errors, such as timeouts and the management of retries. Middleware can be used to provide the logic for error handling and recovery.

• Recovery—A custom retry mechanism needs to be created if quality-of-service requirements dictate it. In this case, it’s important to ensure idempotent design characteristics. Platform event enables subscribers to use the replay ID to fetch messages within a certain time period after those messages were published."

Can anyone please tell me what kind of errors and recovery I will have to take care of in my remote system? Any links will be very helpful for me. I am not using any middleware, in what cases should I consider using a middleware. 

Hello friends, need suggestion please.
I have inherited a trigger written by my predecessor which is throwing exception error. Can someone help in getting this sorted? What is the reason of getting this error ?

****** Code Start ******
trigger OnAccountTrigger on Account (before update, before insert) {
    // Create the map to store mappings
    //Map<String, String> objParentAccountMapping = new Map<String, String>();
    // Create set to store ids
    Set<Id> arParentAccountIds = new Set<Id>();
    // get all the Ids for the accounts that are inserted in that execution context.
    for(Account objAccount : Trigger.New) {
        // Check if we have a person
        if ((objAccount.Person_Account_Parent__c != null) && (objAccount.IsPersonAccount)) {
            // Retrieve the related contact
            // Retrieve the parent account from objAccount.Person_Account_Parent__c
            // Update the local contact from the objAccount.PersonContactId of that retrieved parent
            arParentAccountIds.add(objAccount.Person_Account_Parent__c);
        }
    }
   
    // Store the map   
    Map<Id, Account> objAccountChildContact = new Map<Id, Account>([select Id, PersonContactId from Account WHERE Id IN : arParentAccountIds]);
   
    System.debug('Map');
    System.debug(objAccountChildContact);

    // get all the Ids for the accounts that are inserted in that execution context.
    for(Account objAccount : Trigger.New) {
        // Check if we have a person
        if ((objAccount.Person_Account_Parent__c != null)) {
            // Retrieve the related contact
            // Retrieve the parent account from objAccount.Person_Account_Parent__c
            // Update the local contact from the objAccount.PersonContactId of that retrieved parent

            // Set the contact
           /*below in red is line 32*/
 objAccount.Parent__pc = objAccountChildContact.get(objAccount.Person_Account_Parent__c).PersonContactId; 
            System.debug('Updating contact parent for [' + objAccount.Id + '] to [' + objAccount.Parent__pc +']');
           
        }
    }
}


Error Message:
Apex script unhandled trigger exception by user/organization:
OnAccountTrigger: execution of BeforeUpdate

caused by: System.NullPointerException: Attempt to de-reference a null object

Trigger.OnAccountTrigger: line 32, column 1

***** Code End *****

Thanks in advance !


 
Hi,

I am looking for a email validation in lightning component.

1. Is that possible by using in a component ? without using controller or helper ?

2. If No, Can you guide me to get a following email validation.

3.  It should end with ( .COM). Let's say for example it should the validation if it's  in following format " abc@d.o " .


Regards,
Soundar.
Hi

I'm fairly new to flow development but I'm trying to be a bit efficient when it comes to building them keeping in mind the governor limits. So what I wanted to do was build a master flow which runs when an object is saved which runs various subflows. What I want to do in the master is select the record and pass that off to the subflows which will alter the data and then pass it back out and set a "Data Changed" variable so the master know if it has to save the record. 

Problem seems to be that although I have selected the record out in the master I don't seem to be able to pass that to the input variable on my subflow.

This is my Master Flow

Master Flow
Candidate Record Variable
Candidate Record Variable


Sub Flow
Subflow


The Email action was put in so that I could check that the record selected had been populated when I ran / debugged the flow. Which it was. 

I think the issue is because the Candidate Record input variable is not being set but I'm not sure why.

Anyone that has any ideas would be a life saver.

Thanks
I have created a lookup field on the content version object that I am trying to auto populate whenever a file is uploaded on that object.

I created a trigger but it only works sometimes, and other times it doesn't.

This is the code that I have:

trigger UpdateCVLookup on ContentVersion (after insert) {
    
    Set<Id> contentDocumentIdSet = new Set<Id>();
    
    for(ContentVersion cv:trigger.new)
    {
        if(cv.ContentDocumentId != null)
        {
            contentDocumentIdSet.add(cv.ContentDocumentId);
        }
    }
    
    ContentDocumentLink cdl = [SELECT ContentDocumentId, LinkedEntityId FROM ContentDocumentLink WHERE ContentDocumentId IN:contentDocumentIdSet LIMIT 1];
 
    // Project__c can be replaced with the object that has the lookup relationship.

    List<Project__c> upList = [SELECT Id, name FROM Project__c where Id =:cdl.LinkedEntityId];   
    
    //In the following line, make sure to replace Project__c(The lookup field name) with the api name of the lookup field on the content version object.
    List<ContentVersion> cvList = [SELECT Id, Project__c, ContentDocumentId FROM ContentVersion where Id IN: Trigger.newMap.keySet()];
    
    for(ContentVersion cv:cvList)
    {
        if(upList.size() > 0)
        {//In the next line Project__c is referring to the lookup object.
            for(Project__c p : upList){
                //The following line Project__c is referring to the lookup field on Content Versions.
                cv.Project__c = p.Id; 
            }
        }
        else if(upList.size() > 0){
            //The next two lines containing Project__c are referring to the lookup field on Content Versions
            cv.Project__c = cdl.LinkedEntityId;
        } else {
            //This line below is required so that files can still be uploaded to other objects.
            cv.Project__c = null;
        }
    }
    update cvList;
}
I have a custom object called "Returned Mail". This has a field called "parent record". This is a lookup to Returned Mail record (not itself, a different returned mail record). 
Ex: Test 1 and Test 2 are returned mail records. Test 1 is a lookup on Test 2 and is called as the parent record. When someone creates a new record called Test 3 and tries to set Test 2 as its parent record then, they should be prevented from doing so and the field should populate to Test 1. 

User-added image

User-added image
Hello,

I've been struggling with creating a test class for a custom controller with if statements for a Visualforce page. I have no idea what I'm doing wrong and have looked all over these forums and google for an answer with no luck. If someone could give this a shot and let me know what I am doing wrong that would be amazing.

Here is my controller:
public class SuspectListController {
	public final Account act;
    public SuspectListController(ApexPages.StandardController stdController) {
        this.act = (Account)stdController.getRecord();
    }

    public Id AccountId = ApexPages.currentPage().getParameters().get('id');

    public List<HealthCloudGA__EhrEncounter__c> EHRRecords = [SELECT Name, CreatedDate, HealthCloudGA__HospitalizeDischargeDiagnosis__c
                                                       FROM HealthCloudGA__EhrEncounter__c WHERE HealthCloudGA__Account__c = :AccountId AND CreatedDate = LAST_N_DAYS:365 ORDER BY CreatedDate desc];

    public List<String> RType = new List<String>();
    public List<String> Name = new List<String>();
    public List<String> CDate = new List<String>();
    public List<String> Code = new List<String>();
    public List<String> Description = new List<String>();

    public List<String> getType() {
        for (HealthCloudGA__EhrEncounter__c encounter : EHRRecords) {
             if (!Description.contains(encounter.HealthCloudGA__HospitalizeDischargeDiagnosis__c) && encounter.HealthCloudGA__HospitalizeDischargeDiagnosis__c != null) {
                RType.add('EHR Encounter');
                Name.add(encounter.Name);
                Cdate.add(encounter.CreatedDate.format('MM/dd/yyyy'));
                Code.add('');
                Description.add(encounter.HealthCloudGA__HospitalizeDischargeDiagnosis__c);
            }
        }    
        
        return RType;
    }

    public List<String> getName() {
        return Name;
    }
    
    public List<String> getCDate() {
        return CDate;
    }
    
    public List<String> getCode() {
        return Code;
    }
    
    public List<String> getDescription() {
        return Description;
    }
This controller was created to add field values to a list if they are not on the list already and pass that list to an html table on a Visualforce page (Adding to every list in the first function is a bit funky but it saves from looping through each record in each function). My test class currently passes everything except for the if statement and its contents.

Here is my current test class:
@isTest
private class SuspectListTestClass {
    @testSetup static void testSetup() {
        Account testaccount = new Account();
        testaccount.name = 'Zander Test';
        testaccount.Primary_Insurance__c = 'Test Insurance Company';
        testaccount.Gender__c = 'Male';
        testaccount.County__c = 'Maricopa';
        testaccount.RecordTypeId = '012360000004FEPAA2';
        insert testaccount;
    }

    @isTest static void testEHREncounterPass() {
        Account act = [SELECT Id FROM Account WHERE Name = 'Zander Test' LIMIT 1];
        HealthCloudGA__EhrEncounter__c testencounter1 = new HealthCloudGA__EhrEncounter__c();
        testencounter1.HealthCloudGA__Account__c = act.Id;
        testencounter1.HealthCloudGA__HospitalizeDischargeDiagnosis__c = 'Test';
        insert testencounter1;
        PageReference testpagereference = Page.SuspectList;
        test.setCurrentPage(testpagereference);
        SuspectListController testcontroller = new SuspectListController(new ApexPages.StandardController(act));
        testcontroller.Description.add('');
        String[] record = testcontroller.getType();
        System.assertEquals('EHR Encounter',record[0]);
    }
    
    @isTest static void testEHREncounterFail() {
        Account act = [SELECT Id FROM Account WHERE Name = 'Zander Test' LIMIT 1];
        HealthCloudGA__EhrEncounter__c testencounter2 = new HealthCloudGA__EhrEncounter__c();
        testencounter2.HealthCloudGA__Account__c = act.Id;
        testencounter2.HealthCloudGA__HospitalizeDischargeDiagnosis__c = 'Test';
        insert testencounter2;
        PageReference testpagereference = Page.SuspectList;
        test.setCurrentPage(testpagereference);
        SuspectListController testcontroller = new SuspectListController(new ApexPages.StandardController(act));
        testcontroller.Description.add('Test');
        testcontroller.getType();
    }

    @isTest static void testSuspectListController() {
        Account act = [SELECT Id FROM Account WHERE Name = 'Zander Test' LIMIT 1];
        PageReference testpagereference = Page.SuspectList;
        test.setCurrentPage(testpagereference);
        SuspectListController testcontroller = new SuspectListController(new ApexPages.StandardController(act));
        testcontroller.getName();
        testcontroller.getCDate();
        testcontroller.getCode();
        testcontroller.getDescription();
    }
}
From what I understand you need to have one test where it is meant to pass and one where it is meant to fail. I have made 2 test methods but no matter what I do I can not seem to get one to pass. I get an error from the assertEquals() saying that the index is out of range meaning it did not add "EHR Encounter" to the RType list.

Am I missing something here??
I feel like I have inserted a record that should pass but I guess not.
Please help!

Thanks in advance!

 
Hi All,
         I want to create a validation rule which have conditions below:-
1. When IsReccur__c(checkbox) is true and ReccurWithTime___c(Checkbox) is false and reccurType__c(Picklist) and NumberReccur__c(Picklist) is null than show error :- You cant save record.
2. When IsReccur__c is false and ReccurWithTime___c is also false,
 and EndTime(Date/Time) and startTime(Date/TIme)  is not blank than show error.
3.  When IsReccur__c is True and ReccurWithTime___c is also True,
 and EndTime(Date/Time) and startTime(Date/TIme)  is not blank than show error.
Can anyone help me with this validation?
Hi All,

I am getting system.null pointer exception: attempt to de-reference a null object, when trying to insert a record with null value in date field.
How to resolve this error. Need your assistance to fix this issue.

Below is my Trigger:
Trigger:


trigger insertDailyPractices on Study_Plan__c (after insert) 
{
    System.debug('--- Inside Trigger ---');
    List<Daily_Practice__c> dplist = new List<Daily_Practice__c>();    
    
    for(Study_Plan__c sp : Trigger.New)
    {
            Integer daycount = sp.Phase_Start_Date__c.daysBetween(sp.Phase_End_Date__c); ----/// Getting error in this line.
            
System.debug('--- Inside For Loop ---' + sp.Phase_Start_Date__c);
            System.debug('--- Day Count ---' + daycount);
     
        for(integer i=0; i<=daycount; i++)
        {
            Daily_Practice__c dps = new Daily_Practice__c();
            dps.Due_Date__c = sp.Phase_Start_Date__c.addDays(i) + 1;
            dps.StudyPlan__c = sp.Id;
            dps.Status__c = 'Assigned';
            dplist.add(dps);
        }
    }
    
    if(dplist.size() > 0)
    {
        insert dplist;
    }    
    system.debug('--- Inserted Daily Practice ---'+ dplist.size());
}

Thanks
Hello, I am playing with @future method with below code

public class AccountProcessor {
@future
  public static void countContacts(List<Id> recordIds) {
       string AcName = 'United Oil & Gas%';
       List<AggregateResult> ct_contacts = [Select AccountId, Count(Name) from Contact Where Account.Name Like :AcName group by AccountId ];
       List<Account> Upd_Account = new List<Account>();
       
       system.debug('Count - ' + ct_contacts.size());
      
        for (AggregateResult ar : ct_contacts)  {
            Account acc = new Account();
            acc.Id = ((Id)ar.get('AccountId'));
            acc.Number_of_Contacts__c = ((Integer)ar.get('expr0'));
            Upd_Account.add(acc);
            
        }
      update Upd_Account;
  }
}

and below test calss

@IsTest
public class AccountProcessorTest {
      @IsTest
      private static void testAccountProcessor() {
        Id myId1 = Id.valueOf('0016g000007qSglAAE');
        Id myId2 = Id.valueOf('0016g000007qSgmAAE');
        List<Id> MyList =new List<Id>();
        MyList.add(myId1);
        MyList.add(myId2);
                  
        Test.startTest();
          AccountProcessor.countContacts(MyList);
        Test.stopTest();
          
        // runs callout and check results
        List<AggregateResult> logs = [Select AccountId, Count(Name) from Contact Where AccountId IN :MyList group by AccountId];
        System.assertEquals(0, logs.size());
      }
}

My code is not gettign 100% coverage i treid removing @future as well but it is not executing the SOQL..

Select AccountId, Count(Name) from Contact Where Account.Name Like :AcName group by AccountId

I beleive it is not able to substitute the variable.

14:00:17:006 SOQL_EXECUTE_BEGIN [4]|Aggregations:0|SELECT AccountId, COUNT(Name) FROM Contact WHERE Account.Name LIKE :tmpVar1 GROUP BY AccountId

Is there any lilitation for using AggregateResult?

Thanks,
Sakthi
Hi,

I am looking to see the best approach for Salesforce CI. I have gone through many forum and blogs but haven't been able to grasp them. I tried to setup CI for the entire org but facing a lot of challeges which I guess you guys quite aware of.

What I am looking to do incremental deployment based on the git diff, dynamically generate package.xml based on the metadata committed which I think would be manageable something like sfdc-git-package https://www.npmjs.com/package/sfdc-git-package. I am having a hard time implementing this.

Please someone help
Can someone help me to show how I can change the Sales Console Lightning Layout. Currently it is showing as shown in the screen shot below as 3 Column layout. I wanted to change the layout to show the highlight panel on top. I am finding no help from Salesforce help section or trailhead for this. Please bear in mind I am talking about Lightning Sales Console and not Classic. I did the Edit Page and takes me but doesn't allow me to change the layout. 

User-added image
Is there a way to hide "Save & New" Button from the Task page Layout?

User-added image

I looked at everywhere and couldn't find the solution. I do want to give them Create/Edit Permission so no option there to remove that.

Please help
Custom URL for the cast creating inline headers and side bar. I tried the following addition things

            urlConcat += '&inline=0';
            urlConcat += '&isdtp=lt';
            urlConcat += '&isdtp=nv';
            urlConcat += '&isdtp=vw';

the only one that work is '&isdtp=nv' but after saving the activity, the hyperlink in the related list doesn't work. I have attached a screen shot 

User-added image

Anyone can help?

 
Hi,

I am looking to see the best approach for Salesforce CI. I have gone through many forum and blogs but haven't been able to grasp them. I tried to setup CI for the entire org but facing a lot of challeges which I guess you guys quite aware of.

What I am looking to do incremental deployment based on the git diff, dynamically generate package.xml based on the metadata committed which I think would be manageable something like sfdc-git-package https://www.npmjs.com/package/sfdc-git-package. I am having a hard time implementing this.

Please someone help
Helo Everyone,
  I have written an apex code to get order object data from process builder by using invocable method.
And also I had performed some task like create json data and pass that json data in to webservice to get server resposnse.

Here my code,
public with sharing class OrderActivation
{
     @InvocableMethod(label='getorderid' description='Get order record id from order')
    public static void getdata(getcustomerid[] requests)
    {
        String recordId,bCity,bStreet,bState,bZip,bCountry,sCity,sStreet,sState,sZip,sCountry,orderAmount,cCity,cStreet,cState,cZip,cCountry,cName,cEmail;
         string jsonString;
        for(getcustomerid request : requests)
        {
             recordId=  request.recId;
            System.debug('order Id:::::  '+recordId);            
          RootObject objJSONRoot = new RootObject();  
        Merchant merch = new Merchant();
        merch.signature = '73242ibc7osfsdfb5|tuJEH3gNbeWJsdfsdffIHah||nbobljsdhgfjsdhjbnmdli0poys|doU3HJVosdfsfwefym7MQ44qf7cpn7pc';
        merch.tariff = 10423004;
        Customer cus = new Customer();
        cus.first_name=request.cName;
        cus.last_name=request.cName;
        cus.city=request.cCity;
        cus.sState=request.cState;
        cus.country_code=request.cCountry;
        cus.zip=request.cZip;
        cus.email = request.cEmail;
        cus.customer_ip = '182.156.208.74';
        cus.customer_no = '9265';
        cus.tel ='+49 089 123456';
        cus.mobile = '+49 174 7781423';
        cus.house_no='2';
        Transactions tran = new Transactions();
            tran.payment_type ='INVOICE';
        tran.amount = '100';
        tran.currencyX= 'EUR';
        tran.test_mode='1';
        tran.order_no = '12';  
        Custom cu = new Custom();
        cu.lang='EN';
        objJSONRoot.merchant = merch;
        objJSONRoot.customer = cus;
        objJSONRoot.transactions = tran;
        objJSONRoot.cust = cu;
            
        jsonString = JSON.Serialize(objJSONRoot);
        
        System.debug('jsonString::: ' +jsonString);   
        }
        OrderActivation.OrderGet(recordId,jsonString);
    }
    @future(callout=true)
    public static void OrderGet(string recordId, string jsonString)
    {
          String BodyData = jsonString;
             String OrderId = recordId;
                 System.debug(OrderId);
                    System.debug('Json Body::::'+BodyData);
   
           try
             {
            Order od = new Order(id=OrderId);
             String endpointurl = 'https://sample.webserver';
               Http http = new Http();
            HttpRequest req = new HttpRequest();
            req.setEndpoint(endpointurl);
              //req.setBody(sBody);
            req.setMethod('POST');
            req.setHeader('Accept','application/json');
            req.setHeader('Content-Type', 'application/json');
            req.setHeader('charset','utf-8');
            HttpResponse responseg = http.send(req);
            String response = responseg.getBody();
            System.debug(responseg.getBody());
            System.debug(responseg);
            System.debug(response);     
         
          od.Transaction_Data__c = response;
            update od;  
             
             }
             catch(Exception e){
            System.debug(LoggingLevel.ERROR, e.getMessage());   
        }
     
 }
    public static string generateJSON(String jsonString, String request)
    {
         
        String first_name = 'Max';
        String last_name ='cName';
       //string email ='test@com';
        string customer_ip = '182.156.208.74';
        string customer_no = '9265';
        string tel ='+49 089 123456';
        string mobile = '+49 174 7781423';
        string payment_type = 'INVOICE';
        string amount = '1000';
        string currencyX = 'EUR';
        string test_mode = '1';
        string due_date = '2021-08-05';
        string invoice_ref = 'BNR-14-8410121284';
        string order_no = '84112121084';
        string lang ='EN';
        String city = 'San Francisco';
        String sState = 'CA';
        String zip = '946556105';
        String country_code = 'US';
        
        RootObject objJSONRoot = new RootObject();
                
       String jsonData = JSON.Serialize(objJSONRoot);
       // jsonData = jsonData.replace('"currency":', '"currencyX":');
      //  System.debug(jsonData);
        return jsonData;
       
    }  
   public class RootObject
    {
        public Merchant merchant { get; set;}
        public Customer customer { get; set;}
        public Transactions  transactions {get;set;}
        public Custom cust {get;set;}
    }
    public class Merchant
    {
        public string signature { get; set; }
        public integer tariff { get; set; }
    }
    
    public class Customer
    {
        public string first_name { get; set; }
        public string last_name { get; set; }
        public string email {get;set;}
        public string house_no {get;set;}
        public string street {get;set;}
        public string city {get;set;}
        public string zip {get;set;}
        public string sState {get;set;}
        public string country_code {get;set;}
        public string customer_ip{get;set;}
        public string customer_no{get;set;}
        public string tel{get;set;}
        public string mobile{get;set;}
        
        
    }
    public class Transactions
    {
        public string payment_type {get;set;}
        public string amount {get;set;}
        public string currencyX {get;set;}
        public string test_mode {get;set;}
        public string due_date {get;set;}
        public string invoice_ref {get;set;}
        public string order_no {get;set;}
            
    }
    public class Custom
    {
        public string lang {get;set;}
    }
    
    public class getcustomerid
    {
         //request billing address related invocable variables and make variables as required one  
          @InvocableVariable(required=true)
            public String recId;//Get Order record id
          @InvocableVariable(required=true)
            public String bStreet;
          @InvocableVariable(required=true)
            public String bState;
          @InvocableVariable(required=true)
            public String bCity;
          @InvocableVariable(required=true)
            public String bZip;
          @InvocableVariable(required=true)
            public String bCountry;
        //request shipping address related invocable varibales and makes variables a required one
          @InvocableVariable(required=true)
            public String sStreet;
          @InvocableVariable(required=true)
            public String sState;
          @InvocableVariable(required=true)
            public String sCity;
          @InvocableVariable(required=true)
            public String sZip;
          @InvocableVariable(required=true)
            public String sCountry;
         //request order amount related invocable varibales and makes variables a required one
          @InvocableVariable(required=true)
            public String orderAmount;
        
       // cCity,cStreet,cState,cZip,cCountry,cName;
        
        @InvocableVariable(required=true)
            public String cCity;
        @InvocableVariable(required=true)
            public String cStreet;
        @InvocableVariable(required=true)
            public String cState;
        @InvocableVariable(required=true)
            public String cZip;
        @InvocableVariable(required=true)
            public String cCountry;
        @InvocableVariable(required=true)
            public String cName;
        @InvocableVariable(required=true)
            public String cEmail;
        
    }
    }

I'm getting error like Future methode cannot call from future method or batch class.

Any help!!
Thanks in advance.
 
Hello!
I have a Lightning Component PortalHeader
PortalHeader.cmp looks like this:
<aura:component controller="currentUserInfoCtrl" description="portalHeader" implements="forceCommunity:availableForAllPageTypes" access="global">
    <aura:attribute name="userInfo" type="user"></aura:attribute>
    <aura:handler name="init" value="{!this}" action="{!c.initMe}"/>
    
    <div id="ui-wrapper">
        <div class="container">
    ...
PortalHeaderController.js:
({
    initMe : function(component, event, helper) {

        var action = component.get("c.fetchUser");
    ...
and I am getting an error: 
> ***doInit** is not defined throws at https://.../AP/s/components/c/**PortalHeader.js**:30:17*
Please note: 
  1.  I don't call it doInit I call it initMe function
  2.  even if I rename it to doInit I still get the same error.
  3.  There is no PortalHeader.js file there is PortalHeaderController.js and PortalHeaderHelper.js

Any idea of what is going on here and why am I getting this error?

Thank you very much!


 
@isTest
 

private class AccountWrapper_Tests {
 

  @testSetup
 

  static void loadTestData(){
 

    List<Account> accounts = (List<Account>) Test.loadData(Account.SObjectType, 'accountData');
 

    List<Opportunity> opps = new List<Opportunity>();
 

    for(Account a : accounts){
 

      opps.addAll(TestFactory.generateOppsForAccount(a.id, 1000.00, 5));
 

// Variable does not exist: TestFactory (getting this error)
    }
 

    insert opps;
 

  }
 

  @isTest static void testPositiveRoundedAveragePrice() {
 

    List<AccountWrapper> accounts = new List<AccountWrapper>();
 

    for(Account a : [SELECT ID, Name FROM ACCOUNT]){
 

      accounts.add(new AccountWrapper(a));
 

    }
 

    // sanity check asserting that we have opportunities before executing our tested method.
 

    List<Opportunity> sanityCheckListOfOpps = [SELECT ID FROM Opportunity];
 

    System.assert(sanityCheckListOfOpps.size() > 0, 'You need an opportunity to continue');
 

    Test.startTest();
 

    for(AccountWrapper a : accounts){
 

        
 

        System.assertEquals(a.getRoundedAvgPriceOfOpps(), 1000.00, 'Expected to get 1000.00');
 

        System.assert(!a.isHighPriority());
 

    }
 

    Test.stopTest();
 

  }
 

}

Hi All,

 

string templateId = '00XN0000002LbV8MAK';
string domainUrl = URL.getSalesforceBaseUrl().toExternalForm();
HttpRequest req = new HttpRequest();
req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());
req.setHeader('Content-Type', 'application/json');
req.setEndpoint(domainUrl+'/services/data/v51.0/tooling/query/?q=select+id,SenderType,templateId+from+WorkflowAlert+where+templateId=\''+templateId+'\'');
req.setMethod('GET'); 
Http h = new Http();
HttpResponse res = h.send(req);
system.debug(res.getBody());
Map<String, Object> deserialized = (Map<String, Object>)JSON.deserializeUntyped(res.getBody());
Object data1 = deserialized.get('records');
System.debug(deserialized.get('records'));
System.debug(deserialized.get('size'));

 

res.getBody(); -> {"size":1,"totalSize":1,"done":true,"queryLocator":null,"entityTypeName":"WorkflowAlert","records":[{"attributes":{"type":"WorkflowAlert","url":"/services/data/v51.0/tooling/sobjects/WorkflowAlert/01WN00000005esGMAQ"},"Id":"01WN00000005esGMAQ","SenderType":"CurrentUser","TemplateId":"00XN0000002LbV8MAK"}]}

 

Im trying to get ,"SenderType":"CurrentUser"  value but values is not returning: 

System.debug(deserialized.get('records')); --> [{"TemplateId":"00XN0000002LbV8MAK","SenderType":"CurrentUser","Id":"01WN00000005esGMAQ","attributes":{"url":"/services/data/v51.0/tooling/sobjects/WorkflowAlert/01WN00000005esGMAQ","type":"WorkflowAlert"}}]

 

How to get SenderType Value?

 

Thanks in Advance,

my end i have identified where calling and getting responce  like

assume method return like this

public String responce= '{"responceStatus":"SUCCESS","responceDescription":"Ticket got Generated Successfully","responceCode":"200","externalId":"CXP568a449b69bf","createResponce":{"rdnSequenceItem":[{"type":"networkId","assertion":"NYVZL"},{"type":"accountName","assertion":"ATX"},{"type":"serviceId","assertion":"2122472130"}],"troubleReportId":"VNYI1122933","recivedTime":"2020-03-01T16:05:00Z","commitmentTime":"2020-09-01T21:00:00Z","agentContactPerson":{"name":"ny fsc","phone":2222222222}}}';


converting as wrapperclass
TicketResponse respoce1= new TicketResponse();

respoce1 = (TicketResponse)System.JSON.deserialize(responce, TicketResponse.class);


Case c= new Case();
c.Id='5005G00000jyX8PQAU'
c.Commitment_Date_and_Time__c=reponce1.createResponse.commitmentTime;
update c;

wrapper is 


public TicketResponse{
public String responceStatus;
public String responceDescription;    
public String responseCode;
public String externalId;
public CreateResponse createResponse;
public TicketResponse(){
           createResponse = new CreateResponse();
           }
public class CreateResponse{
public List<RdnSequenceItem> rdnSequenceItem;
public String troubleReportId;
public DateTime commitmentTime;
public AgentContactPerson agentContactPerson;
public CreateResponse(){
         agentContactPerson= NEW AgentContactPerson() ;
         }
         }
         public class RdnSequenceItem    {
public String type;
public String assertion;
}
public class AgentContactPerson    {
public String name;
public String phone;
}

}    

so i have created field in wrapper like
public DateTime commitmentTime;

it is not updating case record is any one give suggetion
i have tryed in string also like taking that as sring field and conveting as datetime field but not parsing.


 
Hi Everyone,

problem statement: 
I am passing a SOQL query through a textArea of my Visualforce page. I want my controller to split the query and get a list of the queried coloums:

For ex. : InputQuery : 'Select Id, Name, Rating from Account' or 
'Select Id,Name,Rating from Account'(without space in fields)

Output result : List<String>= ['id', 'Name','Rating'];

I tried with InputQuery.split(' ') method but unable to get desired result. Please help me with this.
I have a list of Events, some of them are Related To a custom object (Closing__c). I have Apex and SOQL code to query the Events into a List. I would also like to get the data from a field  (i.e. Summary__c) on the Closing that is related to the Event, so I can display that in a LWC. I can get basic info in SOQL using: 
SELECT Id, Subject, WhoId, WhatId, What.Id, Who.Id, Who.Name, What.Name
          FROM Event
But I would like to access other fields on the Closing__c record. What's the best way to do that? 
 
OrderItem is the parent to Object A and Object B.

I want to update Type__c  on Object A (existing records) from Object B when the  Object B records get inserted with the Type__c.

I think I can leverage the OrderItem lookup on both the child objects to have a condition something like 
Trigger :- afterUpdate on Object B

If(objectA.OrderItem == objectB.OrderItem){
objectA.Type__c = objectB.Type__c
list.add(objectA); 
}
update list;

As I am bit new to apex not sure how to go ahead. Need some help on this.
Hi,
I have written following apex class and test class. I'm getting an error saying "List has no rows for assignment to SObject" and my test class is getting failed though my code coverage is 91%. I'd appreciate any assistance.



public  class MMAResultReportController

{
    public List<DOAS_AVS_RESPONSE_LEVEL_1__c> avsresults {get;set;}
    public Test_MMA2__c avsRequest {get;set;}
    public string strRequestID{get;set;}
    
    //public string searchRef{get;set;}
    public  MMAResultReportController(){
        system.debug('####Printing page reference');
        system.debug(System.currentPageReference().getParameters().get('RequestID'));
        strRequestID=System.currentPageReference().getParameters().get('RequestID');
        
        getavsRequest();
    }
    public void getavsRequest(){
        avsRequest= new Test_MMA2__c();
        //system.debug ('####strRequestID is: '+strRequestID);
        //system.debug('####Variable is: ' + strRequestID);
        avsRequest = [select MMA_Request_ID__c,MMA_RecordType__c,MMA_Suffix__c,MMA_DOB__c,MMA_Middle_Name__c,MMA_Flag__c,MMA_Sex__c,MMA_SSN__c,MMA_First_Name__c, MMA_Last_Name__c, MMA_Family_ID__c, MMAReportDate__c,MMA_BENE_SSN1__c,
from Test_MMA2__c where MMA_Request_ID__c =:strRequestID];//                                                                 
    }
    
           
    
}


Test Class-

@isTest(SeeAllData=true)
public class MMAResultReportController_Test {
    @istest static void test(){

        Test_MMA2__c tes= new Test_MMA2__c ();
        tes.name='Sample';
        tes.MMA_First_Name__c='John';
        tes.MMA_Last_Name__c='Smith';
        tes.MMAReportDate__c=date.today();
        tes.MMA_Middle_Name__c='De';
       
        insert tes;
        test.startTest();
     
       MMAResultReportController ce= new MMAResultReportController();
      
        ce.getavsRequest();
        test.stopTest();
    }

 
When a new Non-Primary Contact is created and the Account related to the new Contact does not have any existing Contacts, the new Contact should automatically become the Account's Primary Contact.

Hi experts. Help me on this one. thank you
Hello Experts,

I need a quick confirmation with my code. The requirement is like this.

 1. When I delete/create/update an Account
 2. There is this object called track
 3. I want this object to have the Account Name with type.
trigger TrackMethod on Account (before delete) {
        List<Track__c> tList = new List<Track__c>();
        if(Trigger.isBefore)
        { 
            if(Trigger.isDelete){
                for (Account m : [SELECT Id, Name FROM Account where Id IN :Trigger.old]) {
                    Track__c t = new Track__c();
                    t.Name=m.name;
                    t.action__c='Deleted';
                    t.type__c='Account';
                    tList.add(t);
                }
            }
        }
    else if(Trigger.isAfter) {
            for(Account m:trigger.New){
                Track__c t = new Track__c();
                t.Name=m.name;
                if(Trigger.isInsert){
                    t.action='Created';
                } else if(Trigger.isUpdate){
                    t.action='Updated';
                }
                t.type__c='Method';
                tList.add(t);
            }
        }
        insert tList;
    }
Please let me know if my code is correct.

Thanks
Hi All,

I need to invoke child LWC from parent dyanmically.Below syntax has been given in saleforce documentation for invoking child component.
<c-child-cmp></c-child-cmp>. 

But can i pass this value "c-child-cmp" dynamically. for example
in JS,
var cmpName  = c-child-cmp;

in HTML,
<{cmpName}></{cmpName}>

can i  invoke  like this ? 
Appreciate your help!
Hello,

I written below code and while updating Opportunity record not working. Can anyone Please advise me where it went wrong.

trigger Example5 on Opportunity (before update) {    
    
    //Get Old Data
    Map<Id,Opportunity> oldMap = Trigger.oldMap;
    //Get New Data
    Map<Id,Opportunity> newMap = Trigger.newMap;
    //Get all Keys
    set<ID> idList = oldMap.keySet();
    for(ID key:idList){
        Opportunity old = oldMap.get(key);
        Opportunity newopt = newMap.get(key);
        if(old.StageName!='Closed Own' && newopt.StageName=='Closed Own'){
            newopt.CloseDate=system.today();
            newopt.Type='New Customer';
        }
    }
}
renderedCallback(){
this.template.querySelector('lightning-button.Previous').disabled = true;
}

if i include this line in my code i am getting error as  Error during LWC component connect phase: [Cannot set property 'disabled' of null]

what to do how to rectify this

for full code refer this :https://medium.com/@rs60033/pagination-in-lwc-lightning-web-component-7a6dcb5a9385

and please help me how to rectify this 

syed e h mazhari
mazharibobby829@gmail.com
8328174785

 
With this apex trigger i'm not to modify the record if the stage is equal to Closed Won, but when record is not closed won. Not able to change stage to closed won also. 


trigger OpportunityTrigger on Opportunity(before update, before delete){
   
    
   
for(Opportunity opp1: Trigger.new) {
    if(opp1.StageName == 'Closed Won'){
        opp1.addError('You cannot modified the opportunity when stage is Closed Won.');                    
        
    }
}
Hi, I am getting below Error for below mentioned codes.

"This page has an error. You might just need to refresh it. Unable to find action 'getStringArray' on the controller of c:ApexComponent Failing descriptor: {c:ApexComponent}"

Apex Class:
public class AttributeTypes {
    public final String[] arrayItems;
    
 @AuraEnabled
    public static List<String> getStringArray() {
        String[] arrayItems = new String[]{ 'red', 'green', 'blue' };
        return arrayItems;
    }

}

ApexComponent.cmp:

<aura:component controller="AttributeTypes">
    <aura:attribute name="favoriteColors" type="String[]" default="cyan, yellow, magenta"/>
    <aura:iteration items="{!v.favoriteColors}" var="s">
        {!s}
    </aura:iteration>
    <lightning:button onclick="{!c.getString}" label="Update"/>
</aura:component>

ApexComponentController.js:

({
    getString : function(component, event) {
    var action = component.get("c.getStringArray");
     action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                var stringItems = response.getReturnValue();
                component.set("v.favoriteColors", stringItems);
            }
        });
        $A.enqueueAction(action);
    }
})

ApexApplication.app:

<aura:application >
    <c:ApexComponent/>
</aura:application>
Id recordId = 'xyz';
String objName = recordId.getSObjectType().getDescribe().getName();


I found the object Name but I also want Label for this recordId. How to use getLabel() on a given recordId?