• DIVYANSHU BHUSHAN
  • NEWBIE
  • 10 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 3
    Replies

try{
        con2=[select Contact_Role__c from Contact where id = :app.Student_Alumni_Name__c];
        system.debug('con2---->'+con2);
    
        // Check to see if contact roll is null
        if(con2.Contact_Role__c == NULL)
        {
            con.Contact_Role__c = 'Applicant';
        }
        else
        {
            boolean applicantFound = false;
         
            string[] contactRoleList = con2.Contact_Role__c.split(';',0);
           
            for(String contactRole : contactRoleList)
            {
              
                if(contactRole == 'Applicant')
                {
                    applicantFound = true;
                }
            }
            
          
            if(applicantFound==false)
            {
              
                con.Contact_Role__c = con.Contact_Role__c+'; Applicant';
            }
        }
        update con;
    }catch(System.DmlException e){
        system.debug(LoggingLevel.INFO, 'Contact save failed - ' + e.getMessage() + ',' + e.getLineNumber());
        ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR, 'An unexpected error has occurred saving your application: ' + e.getLineNumber() + ',' + e.getMessage()));

I have this code in my apex class. here app is another object's reference.

While running the code, I am getting this error

"first error: INVALID_CROSS_REFERENCE_KEY, Can not select a person account: [AccountId]".

What shuld I do to remove this error. Thanks in advance. Any help much be appreciated.

Hello friends, I have a schedulable class.
global class SchedulableTNOFTPJob implements Schedulable {
    global void execute(SchedulableContext sc) {
    if ([SELECT count() FROM AsyncApexJob WHERE (JobType='BatchApex' OR JobType='ScheduledApex') AND (Status = 'Processing' OR Status = 'Preparing')] < 5){
            try {
              //for(Integer i=0; i < 50; i++) {
              Datetime sysTime = System.now();
              ProcessTNOFiles batch = new ProcessTNOFiles();
              Id cronId = System.scheduleBatch(batch, 'schedFiles' + sysTime.getTime(), 1);     
              //}
            } catch (System.AsyncException ae) {
              
            }
        } else {
          System.debug(LoggingLevel.WARN,'ProcessTNOFiles Finished');
          //Build the system time of now + 20 seconds to schedule the batch apex.
          Datetime sysTime = System.now();
          Integer rand = Integer.valueOf(Math.Random() * 10);
          sysTime = sysTime.addSeconds(20+rand);
          String chron_exp = '' + sysTime.second() + ' ' + sysTime.minute() + ' ' + sysTime.hour() + ' ' + sysTime.day() + ' ' + sysTime.month() + ' ? ' + sysTime.year();
          system.debug(chron_exp);
          SchedulableTNOFTPJob ftpFiles = new SchedulableTNOFTPJob();
          //Schedule the next job, and give it the system time so name is unique
          Id cronId = System.schedule('ftpFiles' + sysTime.getTime(),chron_exp,ftpFiles);
          System.abortJob(sc.getTriggerId());
          System.debug('*******ProcessTNOFiles FAIL CRON ID: '+cronId+', but MAIN ID: '+sc.getTriggerId());
        }
    }
}

and it's test class is here
@isTest
public class TestSchedulableTNOFTPJob {
    
    static testMethod void myUnitTest() {
    test.startTest();
        AsyncApexJob aa = new AsyncApexJob();
       
	SchedulableTNOFTPJob nightlyUpdate = new SchedulableTNOFTPJob();
	String schedule = '0 0 23 * * ?';
	system.schedule('Nightly Update', schedule, nightlyUpdate);
        
	test.stopTest();
    }
}

But the test class is covering only "IF" condition of schedulable class.Please help. Thanks in anticipation :)
I am querying some fields from an object and saving this into a list. Now I want use one of the field in IF condition, but I am receiving error " Initial term of field expression must be a concrete SObject" at IF condition line.
Please help me with these guys. 
Thanks in advance. :)
Cid = ApexPages.CurrentPage().getparameters().get('id');
list<Client_Intake_Forms__c> conCount = new list<Client_Intake_Forms__c>();
     conCount=[select id,name,Completed__c from Client_Intake_Forms__c where Client__c =:Cid ];
    System.debug('conCount>>>>>>>>>>'+conCount);
	if(conCount.Completed__c == true ){
		ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'This client has a finished intake form. A new intake form cannot be started.'));
		
		System.debug('In error condition');
		
	}

 
I need to show warning message when user close[X] the flow. It is working fine, but it is also showing warning message when click on the pause button and next button. This should not be happening.
 Here is my code :-
<apex:page standardController="Contact" extensions="ContactIntakeFlowController">
    <script type="text/javascript">
     window.onbeforeunload = function() {
       
        return "Did you save your stuff?"
      }
    </script>

<flow:interview name="ClientIntakeFlow_FROM_CONTACT" allowShowPause="true" finishLocation="{!PageA}" pausedInterviewId="{!pausedId}" rendered="{!displayBoolean}">
<apex:param name="ClientIdVar" value="{!Contact.Id}"/> </flow:interview>
    
</apex:page>

Thanks in advance :)
Hello Guys, need some help regarding salesforce flow. I want to change the label of "pause" button on flow. How can I do this ? Please reply ASAP.
Thanks in advance :)
I need to show a warning message, when user click on the close[X] on right upper corner of the window, in a visualforce page. Any suggestiion is much appreciated.
I need to show warning message when user close[X] the flow. It is working fine, but it is also showing warning message when click on the pause button and next button. This should not be happening.
 Here is my code :-
<apex:page standardController="Contact" extensions="ContactIntakeFlowController">
    <script type="text/javascript">
     window.onbeforeunload = function() {
       
        return "Did you save your stuff?"
      }
    </script>

<flow:interview name="ClientIntakeFlow_FROM_CONTACT" allowShowPause="true" finishLocation="{!PageA}" pausedInterviewId="{!pausedId}" rendered="{!displayBoolean}">
<apex:param name="ClientIdVar" value="{!Contact.Id}"/> </flow:interview>
    
</apex:page>

Thanks in advance :)

please tell me about Encrypted Fields in brief? thanks in advanced.?