• GeorgeP
  • NEWBIE
  • 20 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 11
    Replies
Hi,
If a Process Builder flow creates a record, can it return or retrieve that row ID or Name in the same flow so a subsequent action inthe same flow can log something like 'PB flow ABC created row XYZ' ?
P.S., why isnt there a category for Process Builder flow questions??
Is it possible to create or instantiate a class of a type the is equal to the value of a String?    So something along these lines;

//Normal code
private MynewClass MyNewClass;
MyNewClass = new myNewClass();

// Is something like this possible instead?
private MynewClass MyNewClass;
String tempString = 'MyNewClass';
MyNewClass = new tempString();  //  ie somehow get the value of tempString' as the type of class to create.

cheers
George
Hi, can anyone help as to how i can bulkify this code:
Context: A list of accounts is loaded (imported) into a custom VF page, the list is in a .CSV file.  Afeter the list is uploaded to the VF page & viewable by the user they can insert the list into the SF database.    

As part of the load step (or import step) the controller behind the VF page validates the accounts coming in to ensure that they actaully exist on the SF database (ie they have to be exisiting accounts) otherwise an error message is shown telling the user which account doen't exist and the insert button is disabled.   However, the code gets a 'Too many sql queries error' when running with a largish file. 

There are other things going on in the controllwe file so other SQL contribute to the limit being reached, but is there a way that a list can be validated in bulk as currently the list is validated acount by account?     An import file of over 30 accounts is getting the too many SQL query error.  

Here is the SOQL:
1st checks if the account exisit & then checks if the account is associated to an opportunity? 

public static integer validateContractAccount(string contAcct, string SFOppId, string oppId_c, integer errorNum, integer linenum) {
     List<Account> acctList = [SELECT ID, ParentId FROM Account WHERE Account.Sap_ca_Id__c =: contAcct LIMIT 1];    
     if (acctList.size() < 1 ) {  
         errorNum = errorNum + 1;
         ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR, errorNum +  
            ') Contract Account ' + contAcct + ' for site ' + linenum + ' was not found in Salesforce. Data can not be inserted.');
         ApexPages.addMessage(errorMessage);     
       }  
     else {
         List<Contract_Account_Relationship__c> relation = [SELECT ID, Opportunity__c FROM Contract_Account_Relationship__c
                                                                WHERE Account__c =: acctList.get(0).ID and Opportunity__c =: SFOppId];
         if (relation.size() < 1 ) {  
             errorNum = errorNum + 1;
             ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR, errorNum +  
             ') Contract Account ' + contAcct + ' for site ' + linenum + ' is not associated to opportunity ' + oppId_c + '. Data can not be inserted.');
             ApexPages.addMessage(errorMessage);     
            }
        }
    return errorNum;
    } 

The actual insert code (not shown) is bulkified but can the validation code be bulkified?
cheers
Is it possible to create or instantiate a class of a type the is equal to the value of a String?    So something along these lines;

//Normal code
private MynewClass MyNewClass;
MyNewClass = new myNewClass();

// Is something like this possible instead?
private MynewClass MyNewClass;
String tempString = 'MyNewClass';
MyNewClass = new tempString();  //  ie somehow get the value of tempString' as the type of class to create.

cheers
George
Hi, can anyone help as to how i can bulkify this code:
Context: A list of accounts is loaded (imported) into a custom VF page, the list is in a .CSV file.  Afeter the list is uploaded to the VF page & viewable by the user they can insert the list into the SF database.    

As part of the load step (or import step) the controller behind the VF page validates the accounts coming in to ensure that they actaully exist on the SF database (ie they have to be exisiting accounts) otherwise an error message is shown telling the user which account doen't exist and the insert button is disabled.   However, the code gets a 'Too many sql queries error' when running with a largish file. 

There are other things going on in the controllwe file so other SQL contribute to the limit being reached, but is there a way that a list can be validated in bulk as currently the list is validated acount by account?     An import file of over 30 accounts is getting the too many SQL query error.  

Here is the SOQL:
1st checks if the account exisit & then checks if the account is associated to an opportunity? 

public static integer validateContractAccount(string contAcct, string SFOppId, string oppId_c, integer errorNum, integer linenum) {
     List<Account> acctList = [SELECT ID, ParentId FROM Account WHERE Account.Sap_ca_Id__c =: contAcct LIMIT 1];    
     if (acctList.size() < 1 ) {  
         errorNum = errorNum + 1;
         ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR, errorNum +  
            ') Contract Account ' + contAcct + ' for site ' + linenum + ' was not found in Salesforce. Data can not be inserted.');
         ApexPages.addMessage(errorMessage);     
       }  
     else {
         List<Contract_Account_Relationship__c> relation = [SELECT ID, Opportunity__c FROM Contract_Account_Relationship__c
                                                                WHERE Account__c =: acctList.get(0).ID and Opportunity__c =: SFOppId];
         if (relation.size() < 1 ) {  
             errorNum = errorNum + 1;
             ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR, errorNum +  
             ') Contract Account ' + contAcct + ' for site ' + linenum + ' is not associated to opportunity ' + oppId_c + '. Data can not be inserted.');
             ApexPages.addMessage(errorMessage);     
            }
        }
    return errorNum;
    } 

The actual insert code (not shown) is bulkified but can the validation code be bulkified?
cheers