• Biswajit Nath 9
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 4
    Replies
I have a method which runs in the after update trigger of Account.
The Account is a Business Account.
Person Account is also enbled in the org.
The code is called in the following order:
Account Trigger--> Account Handler--> Account Helper

Issue:
When the code is specifically called for Business Account recordtype, somehow a Person Account field is also included in the Trigger variables like Tigger.newmap.

There is no explicite mention of the Person Account field in the Code, but still it is present in the trigger variable.

Salesforce support team is not able to help me on this topic. 
A feasible resolution will be much appriciated.
I am using SOAPUI to post an XML. I have the below XML code: 
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com" xmlns:urn1="urn:sobject.enterprise.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> soapenv:Header urn:OwnerChangeOptions urn:options urn:typeKeepAccountTeam</urn:type> urn:execute1</urn:execute> </urn:options> </urn:OwnerChangeOptions> urn:SessionHeader urn:sessionId</urn:sessionId> </urn:SessionHeader> </soapenv:Header> soapenv:Body urn:upsert urn:externalIDFieldNameSAP_No__c</urn:externalIDFieldName> <urn:sObjects xsi:type="urn1:Account"> urn1:SAP_No__c006851xxx</urn1:SAP_No__c> urn1:Customer_Service_Z6__r urn1:SAP_User_Id__cDExx</urn1:SAP_User_Id__c> </urn1:Customer_Service_Z6__r> urn1:Owner urn1:SAP_User_Id__c00000xxxx</urn1:SAP_User_Id__c> </urn1:Owner> urn1:Sales_Rep_SAP_Z1__r urn1:SAP_User_Id__c00000xxxx</urn1:SAP_User_Id__c> </urn1:Sales_Rep_SAP_Z1__r> </urn:sObjects> <urn:sObjects xsi:type="urn1:Account"> urn1:SAP_No__c00532xxxx</urn1:SAP_No__c> urn1:Customer_Service_Z6__r urn1:SAP_User_Id__cSKxx</urn1:SAP_User_Id__c> </urn1:Customer_Service_Z6__r> urn1:Owner urn1:SAP_User_Id__cV2xxxxx</urn1:SAP_User_Id__c> </urn1:Owner> urn1:Sales_Rep_SAP_Z1__r urn1:SAP_User_Id__cV253xxx</urn1:SAP_User_Id__c> </urn1:Sales_Rep_SAP_Z1__r> </urn:sObjects> </urn:upsert> </soapenv:Body> </soapenv:Envelope>

I am getting the following response:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:enterprise.soap.sforce.com"> soapenv:Header 20018 5000000 API REQUESTS </soapenv:Header> soapenv:Body false OwnerId All accounts must have the same current owner and new owner. INVALID_FIELD 0013N0xxx0pnZxxxAU false false OwnerId All accounts must have the same current owner and new owner. INVALID_FIELD 0013N00xxxxoQAI false </soapenv:Body> </soapenv:Envelope>

Please let me know for any solution to resolve the issue
Hi All,

I am trying to optimize a code.
The code uses nested For loop to compare values from new trigger and old trigger. As a result, some time it hits the Apex CPU Time Limit error for a large volume of data.
I would like to ask if there is any better and efficient way to handle this situation.
Many thanks in advance!
 
Hi All,

I want to use the below code to get all the child relationships of an object(both custom and standard):

Schema.DescribeSObjectResult R = Account.SObjectType.getDescribe();
List<Schema.ChildRelationship> C = R.getChildRelationships();

and want to get the object API name of the relationships as a list of strings. I am not able to figure out how to achive this. Could anybody please help?
Hi,
I am trying to use ToolingAPI to fetch Pagelayout informations. As I am using lightning, so I have created
1.connected app:
Connected App
2.Auth Provider:
Auth Provider3.Named Credential:
Named CredentialPlease find below the the code snippet:
Global with sharing class DocGeneration {
    @AuraEnabled 
    public static String Callout(){;
        String resbody;
        Http http = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint('callout:Tooling_API/services/data/v35.0/tooling/query/?q=Select+Id+from+Layout');  
        req.setMethod('GET');
        req.setHeader('Content-Type', 'application/json;charset=UTF-8');
        system.debug('req:' + req);
        HttpResponse res = new HttpResponse();
        res = http.send(req);
        resbody= res.getBody();
        system.debug('res:' + resbody);
        return resbody; 
    }
}
When I am calling this method from annonymous Apex in developer console, It is returning the status as 200 but HTTPResponse has no body.
User-added image
Am I doing anything wrong? Please help.
There is a custom button on account. When it is being clicked it is navigated into a VF page. My requirment is to make a field in the visual force page available or unavailable depending on the type on access the account team member has.For account team member with read/write access will be able to edit that field and those who have only read only can only see the field. Please could anyone help me to achive this? many thanks in advance.
Hi,
I have 200 reports where there is a filter criteria. due to some changes in a third party application from where salesforce is feeded, the filter value needs to be changed for all 200 reports. Is there any shortcut way to update the filter value in one go? Many thanks in advance.
Hi, I have a controller and a VF page where the vf page takes in a csv file and pass it to the controller. The controller follows a particular logic to create user. I am encountering no error but the list named as 'colleaguelist' is not getting populated.

CONTROLLER:
public class importDataFromCSVController {
public Blob csvFileBody{get;set;}
public string csvAsString{get;set;}
public String[] csvFileLines{get;set;}
public List<User> userlist{get;set;}
public List<Colleague_c__c> colleaguelist;
public List<String> Collid{get;set;}

    public importDataFromCSVController(){
        csvFileLines = new String[]{};
        userlist = New List<User>();
        colleaguelist = New List<Colleague_c__c>();
        collid = New List<String>();
    }
  
  public void importCSVFile(){
       
       try{
           csvAsString = csvFileBody.toString();
           csvFileLines = csvAsString.split('\n');
           System.debug('####csv' + csvFileLines);
           
           for(Integer i=1;i<csvFileLines.size();i++){
               String[] csvRecordData =csvFileLines[i].split(',');
               collid.add(csvRecordData[0]);
               
           }
           System.debug('####collid' + collid);
           colleaguelist = [Select Id, Name, IsActive__c, CompanyName__c, Email__c, EmployeeNumber__c from Colleague_c__c where EmployeeNumber__c in:collid];
           System.debug('####colllist' + colleaguelist);   
           for(Integer i=1;i<csvFileLines.size();i++){
           system.debug('###for1 entered');
               string[] csvRecordData = csvFileLines[i].split(',');
            for(Colleague_c__c coll: colleaguelist){
            system.debug('###for2 entered');
            system.debug('###csvRecordData[0]' + csvRecordData[0]);
            system.debug('###coll.EmployeeNumber__c' + coll.EmployeeNumber__c);
            system.debug('###coll.IsActive__c' + coll.IsActive__c);
                    if(csvRecordData[0] == coll.EmployeeNumber__c && coll.IsActive__c == true){
                       system.debug('###if entered');
                       User use = new User() ;
                       use.LastName = coll.Name ;            
                       use.Email = coll.Email__c;
                       use.Username = coll.Email__c;
                       use.CommunityNickname = coll.Name;
                       use.ProfileId = '00e28000001D7DM';
                       use.UserRoleId = '00E28000001lvac';
                       use.EmployeeNumber__c = coll.EmployeeNumber__c;
                       userlist.add(use);  
           }
           }
           
        
           }
           system.debug('####userlist' + userlist);
           insert userlist;
           System.debug('####List inserted');
       }
        
        catch (Exception e)
        {
            ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR,'An error has occured while importin data Please make sure input csv file is correct');
            ApexPages.addMessage(errorMessage);
         
        }
  } 
  }

VF Page:
<apex:page controller="importDataFromCSVController">
<apex:form >
<apex:pagemessages />
<apex:pageBlock >
<apex:pageBlockSection columns="4">
<apex:inputFile value="{!csvFileBody}" filename="{!csvAsString}"/>
<apex:commandButton value="Import user" action="{!importCSVFile}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

Kindly help. Many thanks in advance.
I have  a piece of code where I am getting error at line 3:
public static list<Account> createaccount(Integer numberofrec){
        List<Account> accounts = new list<Account>();
        RecordType recid = New RecordType([Select Id, name From RecordType where sobjecttype = 'Account' and name ='Account_New_Page_Assignment']);
  Colleague__c colleague = new Colleague__c();
  colleague = createcolleague(1)[0];
        for (Integer i = 0; i< numberofrec; i++){
            Account account = new Account(recordtypeid = recid.Id, Name = 'Test Account' + Math.random(), Relationship_Manager__c = colleague.Id , Country__c = 'India - IN' );
   accounts.add(account);
        }
  return accounts;



Can anybody help me out ? Many thanks in advance.
I have a method which runs in the after update trigger of Account.
The Account is a Business Account.
Person Account is also enbled in the org.
The code is called in the following order:
Account Trigger--> Account Handler--> Account Helper

Issue:
When the code is specifically called for Business Account recordtype, somehow a Person Account field is also included in the Trigger variables like Tigger.newmap.

There is no explicite mention of the Person Account field in the Code, but still it is present in the trigger variable.

Salesforce support team is not able to help me on this topic. 
A feasible resolution will be much appriciated.
Hi All,

I want to use the below code to get all the child relationships of an object(both custom and standard):

Schema.DescribeSObjectResult R = Account.SObjectType.getDescribe();
List<Schema.ChildRelationship> C = R.getChildRelationships();

and want to get the object API name of the relationships as a list of strings. I am not able to figure out how to achive this. Could anybody please help?
Hi,
I am trying to use ToolingAPI to fetch Pagelayout informations. As I am using lightning, so I have created
1.connected app:
Connected App
2.Auth Provider:
Auth Provider3.Named Credential:
Named CredentialPlease find below the the code snippet:
Global with sharing class DocGeneration {
    @AuraEnabled 
    public static String Callout(){;
        String resbody;
        Http http = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint('callout:Tooling_API/services/data/v35.0/tooling/query/?q=Select+Id+from+Layout');  
        req.setMethod('GET');
        req.setHeader('Content-Type', 'application/json;charset=UTF-8');
        system.debug('req:' + req);
        HttpResponse res = new HttpResponse();
        res = http.send(req);
        resbody= res.getBody();
        system.debug('res:' + resbody);
        return resbody; 
    }
}
When I am calling this method from annonymous Apex in developer console, It is returning the status as 200 but HTTPResponse has no body.
User-added image
Am I doing anything wrong? Please help.
Hi, I have a controller and a VF page where the vf page takes in a csv file and pass it to the controller. The controller follows a particular logic to create user. I am encountering no error but the list named as 'colleaguelist' is not getting populated.

CONTROLLER:
public class importDataFromCSVController {
public Blob csvFileBody{get;set;}
public string csvAsString{get;set;}
public String[] csvFileLines{get;set;}
public List<User> userlist{get;set;}
public List<Colleague_c__c> colleaguelist;
public List<String> Collid{get;set;}

    public importDataFromCSVController(){
        csvFileLines = new String[]{};
        userlist = New List<User>();
        colleaguelist = New List<Colleague_c__c>();
        collid = New List<String>();
    }
  
  public void importCSVFile(){
       
       try{
           csvAsString = csvFileBody.toString();
           csvFileLines = csvAsString.split('\n');
           System.debug('####csv' + csvFileLines);
           
           for(Integer i=1;i<csvFileLines.size();i++){
               String[] csvRecordData =csvFileLines[i].split(',');
               collid.add(csvRecordData[0]);
               
           }
           System.debug('####collid' + collid);
           colleaguelist = [Select Id, Name, IsActive__c, CompanyName__c, Email__c, EmployeeNumber__c from Colleague_c__c where EmployeeNumber__c in:collid];
           System.debug('####colllist' + colleaguelist);   
           for(Integer i=1;i<csvFileLines.size();i++){
           system.debug('###for1 entered');
               string[] csvRecordData = csvFileLines[i].split(',');
            for(Colleague_c__c coll: colleaguelist){
            system.debug('###for2 entered');
            system.debug('###csvRecordData[0]' + csvRecordData[0]);
            system.debug('###coll.EmployeeNumber__c' + coll.EmployeeNumber__c);
            system.debug('###coll.IsActive__c' + coll.IsActive__c);
                    if(csvRecordData[0] == coll.EmployeeNumber__c && coll.IsActive__c == true){
                       system.debug('###if entered');
                       User use = new User() ;
                       use.LastName = coll.Name ;            
                       use.Email = coll.Email__c;
                       use.Username = coll.Email__c;
                       use.CommunityNickname = coll.Name;
                       use.ProfileId = '00e28000001D7DM';
                       use.UserRoleId = '00E28000001lvac';
                       use.EmployeeNumber__c = coll.EmployeeNumber__c;
                       userlist.add(use);  
           }
           }
           
        
           }
           system.debug('####userlist' + userlist);
           insert userlist;
           System.debug('####List inserted');
       }
        
        catch (Exception e)
        {
            ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR,'An error has occured while importin data Please make sure input csv file is correct');
            ApexPages.addMessage(errorMessage);
         
        }
  } 
  }

VF Page:
<apex:page controller="importDataFromCSVController">
<apex:form >
<apex:pagemessages />
<apex:pageBlock >
<apex:pageBlockSection columns="4">
<apex:inputFile value="{!csvFileBody}" filename="{!csvAsString}"/>
<apex:commandButton value="Import user" action="{!importCSVFile}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

Kindly help. Many thanks in advance.