• Shiva Rajendran
  • SMARTIE
  • 507 Points
  • Member since 2015
  • Salesforce Developer


  • Chatter
    Feed
  • 8
    Best Answers
  • 2
    Likes Received
  • 1
    Likes Given
  • 27
    Questions
  • 192
    Replies
Hi All,

I have a mobile app(not a salesforce app) which is connected to Salesforce.com and salesforce.com talks to an external website(fulfillment portal) using HTTP REST Request and Response method call out ,now problem is whenever user who wishes to buy a new phone enters his/her details like name,phone model name and his phone number from app and visits physical store outlet for fulfillment,the store representative unable to search the customer data in fulfillment portal..So the store has to manually re-enter customer details.

Integration apex class has been exposed as a WebService
 
public class HttpIntegration{

public String getCalloutResponseContents(String url){

Http h = new Http();

HttpRequest req = new HttpRequest();
req.setEndpoint(url);
req.setMethod('GET');

HttpResponse res = h.send(req);
return res.getBody();


}



 }

While manually testing from Salesforce ,we get a success response from external website(fulfillment portal) and Trigger is also created at Salesforce end to update the Token id at the Order custom object ,but still when the customer goes to store he is unable to find his details,

What can be the possible solution to fix this?

Thanks,
Carolyn
I am a beginner, I wrote this code to basically take two JSON POSTS and combine them I am getting a Save Error: Missing Return Statement Required return type string. My code is as follows, any help would be great! I have a return statement and it is a string so i'm not sure what I am missing. 
global with sharing class SendMCAwFiles {
  	global SendMCAwFiles (ApexPages.StandardController stdController)
  {
  }
  
  
 @RemoteAction
    global static String submittoMCAwDocs(List<Id>attachmentIds, String parentId, String mcaSubmissionID, String app_id,boolean allow_resubmit) {
    
    List<String> files = new List<String>();

    String documentUL_json;
    String response;
    MCA_Submission__c mcaSub = [SELECT Id,App_ID__c, Error_Message__c,FP_URL__c, Submission_Date_Time__c,FP_Username__c, FP_Password__c, Opportunity__c FROM MCA_Submission__c WHERE Id = :mcaSubmissionId];

    for (String attachmentId : attachmentIds) {
      documentUL_json = '';
      response = '';
      
      cg__OpportunityFile__c file = [SELECT Id, cg__File_Size__c, CreatedDate, MCA_Doc_Type__c, cg__Content_Type__c, cg__File_Name__c, MCA_File_Upload_Date__c FROM cg__OpportunityFile__c WHERE Id = :attachmentId];
      string fileURL = cg.SDriveTools.getAttachmentURL(parentId, attachmentId, 7200000);
      
      system.debug('UPLOAD FILE: ' + file.Id + ', URL: ' + fileURL);

        documentUL_json = MCAJSONUploadDocument.MCAJSONUploadDocument(
                mcaSub.FP_Username__c,
                mcaSub.FP_Password__c,
                mcaSub.Id,
                file.MCA_Doc_Type__c,
                file.cg__File_Name__c,
                fileURL
        );
     
    }
    
// now all documents that are attached are  stored withing the DocumentUL__Json string 

        if(mcaSub.App_ID__c != null && !allow_resubmit) {
        	
           system.debug('App has already been submitted.');
           
        } else {

            String jsonRequest=MCAJsonConstruct.MCAJsonConstruct(mcaSubmissionID);
            
            System.debug('MCA Json Request: ' + jsonRequest);
            
            Datetime currentDateTime = Datetime.now();
            String results;
            String DocwSub = documentUL_json + jsonRequest;
            
            try {
                Http httpProtocol = new Http();
		        HttpRequest request = new HttpRequest();
                request.setEndPoint(mcaSub.FP_URL__c+'submit_application with documents');
                request.setMethod('POST');
                request.setTimeout(120000);
                request.setHeader('Content-Type', 'application/json');
                //  set body to DowwSub which is the String for hte document attachment plus the Object.
                request.setBody(DocwSub);
                HttpResponse json_response = httpProtocol.send(request);
                String response2 = json_response.getBody();
                System.debug('MCA Json Response: ' + response);
               
				JSONParser parser =  JSON.createParser(response);
				
				string  IsError='';
				string  Message='';
				string  RowId='';

				//parser response  
                while (parser.nextToken() != JSONToken.END_OBJECT) {
                    if (parser.getCurrentToken() == JSONToken.FIELD_NAME) {
                        String text = parser.getText();
                        String fieldName = parser.getCurrentName();
                        if (parser.nextToken() != JSONToken.VALUE_NULL) {
                            if (text == 'IsError') {
                                IsError = parser.getText();
                            } else if (text =='Message') {
                                parser.nextValue();
                                Message = parser.getText();
                            } else if (text == 'RowId') {
                                RowId= parser.getText();
                            } else {
                                System.debug(response);
                            }
                        }
                    }
                }  // end while
               
                if(IsError == 'false') {
                    mcaSub.App_ID__c = RowId;
                    results = 'Send to MCA was: ' + Message;
                } else {
                    results = 'There was a problem: ' +  Message;
                    System.debug('PROBLEM: ' +  Message);
                }
                mcaSub.Submission_Date_Time__c = currentDateTime;
                mcaSub.Error_Message__c =  Message;

                update mcaSub;

            } catch(System.CalloutException e) {
                System.debug('FAILED: ' + e);
                results = 'ERROR: ' + e;
            }
            return results;
        }  // end if (mca.App_ID__c != null && !allow_resubmit)
    }  // end Pequalwdocs
       
  }

Hi, 

I want to Map a standard field value (Type String e.g. name) of each User (in users), in case it is not null or '',  with a standard SObject.

The DeveloperName of the SObject and the fieldvalue of the User are beeing the connection of these two. means DeveloperName =: user.fieldValue

But in order to refere to every User of users I would need to write this select inside the for loop and that is not a good way of writing a loop. 

How can I map the right name to the right SObject? Could please someone give me a hint? 

I have come to this result so far, but am very unsure if that is a valid solution:

public static boolean methodname (List <User> user, Map)
       Map <String, SObject> resultMap = new Map <String, SObject>();
       SObject so = [SELECT Id FROM SObject];
   
       for(User u : users){
            if(u.Name != null || u.Name != ' ' ){
                resultMap.put(u.name, so);
                   return true;
            }
        }
          return false;
}

 

Thank you in advance. 

Hi Team,

i am trying to get map<user, List<lead>>(), List of lead is records created by the user. I think query for getting related list will not work here.

How do i achieve this.

Thanks,

Manohar

Hi all, I've just written my second trigger and it seems that I'm needing to learn more about how to optimize my code. My trigger runs through the campaign members of a campaign and changes the member status of any email duplicates (but leaves one) so  that an email isn't sent twice to one emails. As a nonprofit many of our donors share an email address in their household so we removing the email addresses from the contacts isn't possible. To help with this, I wrote the trigger below. It worked great in testing on a few hundred campaign members but when I tested it on a few thousand I recieved the dreaded 'System.LimitException: Apex CPU time limit exceeded'.

Could anyone help me optimize this code? I'd love to learn how and apply this knowledge to future triggers. Thank you!
 
trigger CleanEmailAddresses on Campaign (after update) {

	for (Campaign camp : Trigger.new) {
				
		// Check for clean email addresses trigger
		if (camp.clean_emails__c == true) {

			if (camp.IsActive && camp.Status != 'Completed' && camp.Status != 'Aborted') {

			// Counters used later
			Integer uniqueEmailCount = 0;
			Integer dupeCounter = 0;

			// Initialize list that will hold duplicate email addresses
			List<CampaignMember> theseAreTheDupes = new List<CampaignMember>();

			// Check to see if campaign has member status 'Email Duplicate'
			List<CampaignMemberStatus> campaignStatuses = [SELECT Id,
																  Label,
																  CampaignId
															 FROM CampaignMemberStatus
														    WHERE CampaignId = :camp.Id AND
														    	  Label 	 = 'Email Duplicate'];

			// No? Then create it
			if (campaignStatuses.size() == 0) {

				CampaignMemberStatus newCampaignMemberStatus = new CampaignMemberStatus();
				newCampaignMemberStatus.Label 				 = 'Email Duplicate';
				newCampaignMemberStatus.CampaignId 			 = camp.Id;
				insert newCampaignMemberStatus;

			}

			// Create list of email addresses already in campaign that do not have duplicate status
			List<CampaignMember> campaignMembers = [SELECT Id,
														   Email,
														   Status
													  FROM CampaignMember
													 WHERE CampaignId 	= :camp.Id AND
													 	   Status      != 'Email Duplicate' AND
													 	   HasResponded = false];

			
			// Initialize string set that will hold list of unique email addresses
			Set<string> uniqueEmails = new Set<string>();


			// Populate set with unique emails
			for (CampaignMember addToUniqueEmailSet : CampaignMembers) {
								
				uniqueEmails.add(addToUniqueEmailSet.Email);

			}

			// Loop through each unique email address
			for (String uniqueEmailList: uniqueEmails){
				
				// Loop through email campaign member
				for (Integer i = 0; i < campaignMembers.size(); i++) {
					

					// Check to see if current campaign member's email address matches unique address of current iteration
					if (campaignMembers.get(i).Email == uniqueEmailList) {

						// Count number of dupes
						uniqueEmailCount = uniqueEmailCount + 1;

						// Check to see if duplicate is the first one or note
						if (uniqueEmailCount > 1) {

							// If dupe is not the first, add to list of campaign members to change later
							theseAreTheDupes.add(campaignMembers.get(i));
							

						}

					}

				}
				
				// Reset counter
				uniqueEmailCount = 0;

			system.debug ('dupe list size: '+ theseAreTheDupes.size());	

			}

			if (theseAreTheDupes.isEmpty() == false) {

				for (CampaignMember cmChangeStatus : theseAreTheDupes) {

					theseAreTheDupes.get(dupeCounter).Status = 'Email Duplicate';
					dupeCounter = dupeCounter + 1;

				}

				update theseAreTheDupes;

			}

			} else {

				camp.addError('Whoa there partner! 🐴  Emails can not be cleaned from inactive, aborted or completed campaigns!');

			}

		}

	}

}

 
Hi guys,
I'm trying here to get a PDF from SF page. Therefore, I am creating the page on visualforce. 
I am not a coder so I made the document on Word, saved as HTML and copied the code to my visualforce. 

However, it seems that the writing is not the same as I had to add quotes and end tags like <\meta>. I did all that and in the end, I got the error : element <o:p> not known.

So I tried with Google Sheets to download as HTML and same : I have to close all elements again.

Help! :p

Here is the error : line 6, column 3: The element type "meta" must be terminated by the matching end-tag "</meta>"
Error: The element type "meta" must be terminated by the matching end-tag "</meta>".

Here is my current code :
<apex:page standardController="Account" renderAs="pdf" applyBodyTag="false">
  <head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type">
<style type="text/css">
@import url('https://themes.googleusercontent.com/fonts/css?kit=fpjTOVmNbO4Lz34iLyptLVumN3ATOVc2BoeDKcwJhFTljiSzuFEcjsip7pjNdcnF');ol{margin:0;padding:0}table td,table th{padding:0}.c13{border-right-style:solid;padding:0pt 5.8pt 0pt 5.8pt;border-bottom-color:#000000;border-top-width:0pt;border-right-width:0pt;border-left-color:#000000;vertical-align:top;border-right-color:#000000;border-left-width:0pt;border-top-style:solid;border-left-style:solid;border-bottom-width:0pt;width:261.4pt;border-top-color:#000000;border-bottom-style:solid}.c12{color:#000000;font-weight:700;text-decoration:none;vertical-align:baseline;font-size:12pt;font-family:"Adobe Fan Heiti Std B";font-style:normal}.c2{color:#000000;font-weight:400;text-decoration:none;vertical-align:baseline;font-size:9pt;font-family:"Calibri";font-style:normal}.c6{color:#000000;font-weight:400;text-decoration:none;vertical-align:baseline;font-size:11pt;font-family:"Calibri";font-style:normal}.c10{color:#000000;font-weight:400;text-decoration:none;vertical-align:baseline;font-size:12pt;font-family:"Calibri";font-style:normal}.c4{padding-top:0pt;padding-bottom:0pt;line-height:1.0;text-align:right;margin-right:-5.5pt}.c9{padding-top:0pt;padding-bottom:0pt;line-height:1.0;text-align:left}.c0{padding-top:0pt;padding-bottom:0pt;line-height:1.0;text-align:justify}.c5{margin-left:-5.8pt;border-spacing:0;border-collapse:collapse;margin-right:auto}.c8{font-size:9pt;color:#1155cc;text-decoration:underline}.c3{background-color:#ffffff;max-width:529pt;padding:28.4pt 40.5pt 70.8pt 42.5pt}.c7{color:inherit;text-decoration:inherit}.c1{height:11pt}.c11{height:134pt}.title{padding-top:24pt;color:#000000;font-weight:700;font-size:36pt;padding-bottom:6pt;font-family:"Calibri";line-height:1.0;page-break-after:avoid;text-align:left}.subtitle{padding-top:18pt;color:#666666;font-size:24pt;padding-bottom:4pt;font-family:"Georgia";line-height:1.0;page-break-after:avoid;font-style:italic;text-align:left}li{color:#000000;font-size:11pt;font-family:"Calibri"}p{margin:0;color:#000000;font-size:11pt;font-family:"Calibri"}h1{padding-top:12pt;color:#2f5496;font-weight:700;font-size:18pt;padding-bottom:0pt;font-family:"Cambria";line-height:1.0;page-break-after:avoid;text-align:left}h2{padding-top:2pt;color:#2f5496;font-weight:700;font-size:13pt;padding-bottom:0pt;font-family:"Calibri";line-height:1.0;page-break-after:avoid;text-align:left}h3{padding-top:14pt;color:#000000;font-weight:700;font-size:14pt;padding-bottom:4pt;font-family:"Calibri";line-height:1.0;page-break-after:avoid;text-align:left}h4{padding-top:12pt;color:#000000;font-weight:700;font-size:12pt;padding-bottom:2pt;font-family:"Calibri";line-height:1.0;page-break-after:avoid;text-align:left}h5{padding-top:11pt;color:#000000;font-weight:700;font-size:11pt;padding-bottom:2pt;font-family:"Calibri";line-height:1.0;page-break-after:avoid;text-align:left}h6{padding-top:10pt;color:#000000;font-weight:700;font-size:10pt;padding-bottom:2pt;font-family:"Calibri";line-height:1.0;page-break-after:avoid;text-align:left}</style>
</head>
<body class="c3">
<p class="c9 c1" id="h.gjdgxs">
<span class="c6">
</span>
</p>
<a id="t.43237f724b83829791a3600f5d7a15de7edeb72b">
</a>
<a id="t.0">
</a>
<table class="c5">
<tbody>
<tr class="c11">
<td class="c13" colspan="1" rowspan="1">
<p class="c0">
<span style="overflow: hidden; display: inline-block; margin: 0.00px 0.00px; border: 0.00px solid #000000; transform: rotate(0.00rad) translateZ(0px); -webkit-transform: rotate(0.00rad) translateZ(0px); width: 211.94px; height: 100.48px;">
<img src="https://c.eu4.visual.force.com/resource/1494428198000/Logo_2017" style="width: 211.94px; height: 100.48px; margin-left: -0.00px; margin-top: -0.00px; transform: rotate(0.00rad) translateZ(0px); -webkit-transform: rotate(0.00rad) translateZ(0px);" title="">
</span>
</p>
<p class="c0">
<span class="c2">
Pleyad Pôle Business - Immeuble Pleyad 2</span>
</p>
<p class="c0">
<span class="c2">47 boulevard Ornano</span>
</p>
<p class="c0">
<span class="c2">93521 Saint Denis – France</span>
</p>
<p class="c0">
<span class="c2">Tel&nbsp;: +33 1 48 20 20 30</span>
</p>
<p class="c0">
<span class="c8">
<a class="c7" href="https://www.google.com/url?q=http://www.neofi-solutions.com&amp;sa=D&amp;ust=1494580227154000&amp;usg=AFQjCNG-79zmNmJ099Yk2AO5_V_zrntviA">www.neofi-solutions.com</a>
</span>
</p>
<p class="c0 c1">
<span class="c2">
</span>
</p>
</td>
<td class="c13" colspan="1" rowspan="1">
<p class="c4 c1">
<span class="c12">
</span>
</p>
<p class="c4 c1">
<span class="c12">
</span>
</p>
<p class="c4">
<span class="c12">FACTURE N°&nbsp;{!order.OrderNumber}</span>
</p>
<p class="c4">
<span class="c10">Date d’émission : {!Now()}</span>
</p>
</td>
</tr>
</tbody>
</table>
<p class="c9">
<span style="overflow: hidden; display: inline-block; margin: 0.00px 0.00px; border: 0.00px solid #000000; transform: rotate(0.00rad) translateZ(0px); -webkit-transform: rotate(0.00rad) translateZ(0px); width: 340.23px; height: 148.85px;">
<img src="https://c.eu4.visual.force.com/resource/1494436004000/Encadre_facture" style="width: 340.23px; height: 148.85px; margin-left: 0.00px; margin-top: 0.00px; transform: rotate(0.00rad) translateZ(0px); -webkit-transform: rotate(0.00rad) translateZ(0px);" title="">
</span>
<span style="overflow: hidden; display: inline-block; margin: 0.00px 0.00px; border: 0.00px solid #000000; transform: rotate(0.00rad) translateZ(0px); -webkit-transform: rotate(0.00rad) translateZ(0px); width: 340.23px; height: 148.85px;">
<img src="https://c.eu4.visual.force.com/resource/1494436004000/Encadre_facture" style="width: 340.23px; height: 148.85px; margin-left: 0.00px; margin-top: 0.00px; transform: rotate(0.00rad) translateZ(0px); -webkit-transform: rotate(0.00rad) translateZ(0px);" title="">
</span>
</p>
<p class="c1 c9">
<span class="c6">
</span>
</p>
<p class="c0 c1">
<span class="c2">
</span>
</p>
</body>
  </apex:page>
Thank you so much in advance !
 
Hi all,

I am trying to create a bullet point list in a table in Visualforce. See below for my current code. I would like bullet points where every time where I have noted ***.
 
<table style="float: left" border="0" cellpadding="8" cellspacing="0" width="100%">        
<tr >
<td width="50%">
<b><span style="font-size: 11pt;">Take your seat</span></b><br/>
Your space at&nbsp;<apex:outputText value="{!Proposal__c.Building__r.Name}"/>&nbsp;comes with everything you need to get started as soon as you move in - all included in the price:<br/>
<br/>
*** Office furniture package including desk and adjustable office chair.<br/>
<br/>
*** Telephony package including 2,000 minutes per month and a handset.<br/>
<br/>
*** High speed, fully inclusive internet package with optional upgrade to 100mb line.<br/>
<br/>
<b><span style="font-size: 11pt;">Join the&nbsp;<apex:outputText value="{!Proposal__c.Building__r.Name}"/>&nbsp;community</span></b><br/>
When you move into&nbsp;<apex:outputText value="{!Proposal__c.Building__r.Name}"/>, you get more than just workspace. You’ll be able to move into an active community made up of like-minded businesses.<br/>
<br/>
*** Customer Steering Group to give you a say in the running of the building.<br/>
<br/>
*** Community Engagement Manager to build the&nbsp;<apex:outputText value="{!Proposal__c.Building__r.Name}"/>&nbsp;community.<br/>
<br/>
*** Onsite customer service team.<br/>
<br/>
*** Regular programme of business, social and wellbeing events.
</td>
<td width="50%">
<b><span style="font-size: 11pt;">The Bruntwood Way</span></b><br/>
We prefer to think of ourselves as your property partner, not your landlord. When your business succeeds, our can too so that’s why we work hard to provide the best service possible.<br/>
<br/>
*** <b>Peace of mind</b><br/>
We own and manage all of our own buildings so you can be sure there will always be a member of the Bruntwood team on hand to help.<br/>
<br/>
*** <b>Flexibility</b><br/>
As your business grows you can move around the Bruntwood portfolio whenever you need more space - even if your current contract hasn’t ended.<br/>
<br/>
*** <b>Value for money</b><br/>
Managing our buildings ourselves means that we can often provide more cost effective solutions across our range of properties.<br/>
<br/>
*** <b>Responsible</b><br/>
From recycling to improving energy efficiency, we take our commitment to the protecting the environment seriously. We believe we are good people to do business with and always work with suppliers who are too.
                                  
</td>
</tr>                       

</table>
Any help would be greatly appreciated.

Thanks,

Paul
 
Here is my code:

trigger AggregateResult on Contact (after insert, after update) {

if((trigger.isinsert && trigger.isafter) || (trigger.isupdate && trigger.isafter))
{
contact c=trigger.new[0];
if(c.accountid!=null)
{

AggregateResult[] ar=[select SUM(Contact_Amount__c) ss from contact where accountid=:c.accountid];

Integer d=(Integer)ar[0].get('ss');

account ac=new account(id=c.accountid);
  ac.Total_Amount_of_Contacts__c=decimal.valueOf(String.valueOf(ar[0].get('ss')));
  update ac;
}
}

}

I want the sum of Amount field in Contact to appear on Account field. But I'm getting this error:
Apex trigger AggregateResult caused an unexpected exception, contact your administrator: AggregateResult: execution of AfterUpdate caused by: System.TypeException: Invalid conversion from runtime type Decimal to Integer: Trigger.AggregateResult: line 11, column 1

Please provide me a solution for this.
I want to understand if a batch class with 1million records are run , will it executes 200 records per batch after batch? I mean by , at any point of time only 1 batch of records are executed? or is it like n number of batches of records can run parallelly too?
Want to understand if only 1 batch of records will be locked at any given records or it can be more.
Thanks,
Shiva RV
I have a batch class which simply reads all the records and update a checkbox and add *10 to a integer field value.
Now i have mimiced the same functionality using a schedular , i want to understand the disadvange or the effectiveness of this approach in salesforce.

Schedular Class which schedules the schedular that act as batch class

Section 1 (Batch Class mimic Schedular implementation): 
global class SchedularToScheduleSchedular_sch implements Schedulable {
    global void execute(SchedulableContext ctx) {
	
		SchedularMimicBatch schdu = new SchedularMimicBatch(); 
		schdu.execute(null);
    }
}

Batch Mimicing Schedular :
 
global class SchedularMimicBatch implements Schedulable{
	global final Integer recordSize;
    
    global SchedularMimicBatch(integer recordSize)
    {
        this.recordSize=recordSize;
        
    }
    global SchedularMimicBatch()
    {
        this.recordSize=200;
        
    }
    global void execute(SchedulableContext ctx) {
        try{
        List<shivaKalinga__BatchScheduleEg__c> currentRecordsToProcess=[select id,shivaKalinga__isValidated__c,shivaKalinga__intData__c from shivaKalinga__BatchScheduleEg__c where shivaKalinga__isValidated__c=false limit :recordSize];
        if(currentRecordsToProcess.size()!=0)
        {
           
            for(shivaKalinga__BatchScheduleEg__c ind:currentRecordsToProcess)
        {
            ind.shivaKalinga__isValidated__c=true;
            ind.shivaKalinga__intData__c=(ind.shivaKalinga__intData__c*10);
        }
            update currentRecordsToProcess;
            for (CronTrigger ct : [SELECT Id FROM CronTrigger]) {
                System.debug(ct.Id);
                   				 System.abortJob(ct.Id);

            }
            SchedularMimicBatch schdu = new SchedularMimicBatch(200); 
			schdu.execute(null);
        }
        
        else
        {
             for (CronTrigger ct : [SELECT Id FROM CronTrigger]) {
                System.debug(ct.Id);
   				 System.abortJob(ct.Id);
			}
        }
        }
        catch(Exception e)
        {
            System.debug('error found');
        }
    }
}
In execute anonymous execute this to execute the schedular :
SchedularToScheduleSchedular_sch abc = new SchedularToScheduleSchedular_sch(); 
abc.execute(null);



Section 2  (Actual Batch Implementation) :

Schedular to Batch :
global class SchedularToScheduleBatch_sch implements Schedulable {
  public static String CRON_EXP = '0 0 0 3 9 ? 2022';
    global void execute(SchedulableContext ctx) {
		/*CronTrigger ct = [SELECT Id, CronExpression, TimesTriggered, NextFireTime
			FROM CronTrigger WHERE Id = :ctx.getTriggerId()];
		System.assertEquals(CRON_EXP, ct.CronExpression);
        System.debug(CRON_EXP);
        System.debug(ct);

    	System.debug(ctx );*/
		Database.executeBatch(new BatchClass_batch(),200); 
	}
}

Batch Class :
 
global class BatchClass_batch implements Database.Batchable<sObject>{
global final String query;
    global BatchClass_batch()
    {
        query='select id,shivaKalinga__isValidated__c,shivaKalinga__intData__c from shivaKalinga__BatchScheduleEg__c';
    }
global Database.QueryLocator start(Database.BatchableContext BC){
      return Database.getQueryLocator(query);
   }

   global void execute(Database.BatchableContext BC, List<sObject> scope){
     for(sobject s : scope){
         Integer ii=Integer.valueOf(s.get('shivaKalinga__intData__c'));
         	ii*=10;
			s.put('shivaKalinga__intData__c',ii);
         	s.put('shivaKalinga__intData__c',true);
     }
     update scope;
    }

   global void finish(Database.BatchableContext BC){
   }
}
In execute anonymous execute this to execute the schedular :
 
SchedularToScheduleBatch_schabc = new SchedularToScheduleBatch_sch(); 
abc.execute(null);

Both Section 1 and Section 2 give's the same result and will work for huge data. 
Is there any disadvantages in using the second approach instead of batch class? Since if it doesn't,  it will help in running more batch class execution concurrently or can be used to run 5 batch class and one batch mimic at the same time.

Thanks and Regards,
Shiva RV





SchedularToScheduleBatch_sch
I got the following error on the second question in the above mentioned superbadge.
Challenge Not yet complete... here's what's wrong: 
There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: EBBHWBTH
I used a fresh new developer org , after getting similar error in new trailhead playground org.
I really wonder why salesforce keep on realeasing new superbadge while the debug on error throwing is so bad, feeling very bad about the superbadge experience error notification of salesforce.
Thanks,
Shiva RV
The salesforce if it involves too much coding ,then i noticed lot of complexities in the code whenever the salesforce updates some of its featues, i would like to know why would someone go for hardcore customization in salesforce instead of choosing  java and heroku? In this case ,their are quite a lot of advantages like
1: no limits as in salesforce
2: licenses are cheap so if the user count is high , it will profitable in the long run
3: No need to have dependency on the existing functionality which may mess with the functionality required.( i have personally been through this, where an existing functionality completely complicated the custom development required)
4: And also need not concern the code breaking because of any standard functionality changes in salesforce ( i have been through this when creating the dynamic thread id in salesforce ,it crashes at some time and no guarante will it work later)

Do share your thoughts to it.

Thanks and Regards,
Shiva RV
Hi everyone,
I have to escalate an case based on time entry. I mean after 5mins the case must be escalated in case rule entry
I have used the formula
((NOW() -CreatedDate)>= 0.00044)
The case entry always fails since the escalation rule is calculated only during the creation time.
Is there any way i can make the escalation rule to fire at 5mins of case creation.
I have also attached a 30mins timed escalation action to the escalation rule.If the rule passes in 30 mins the escalation happens.
Any suggestion on it?
Is it possible to do a soap callout to org 2 from org 1 using javascript in salesforce .
I mean by there exists a soap or rest webservice in org 2, i must write javascript code to access its response in org 1.
I know it is possible using apex and visualforce,just want to confirm its feasibiltiy using javascript
I got the Following Error on the last module even when i tried with a new sfdc developer org.

Challenge Not yet complete... here's what's wrong: 
There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: FMZJJISKUser-added image
Hello Everyone,
I have a component , which creates lightning:button dynamically in iteration. Could i get all the buttons created in the js controller by some logic?
I just want to disable one button out of the 25 dynamically created button.

Cmp:
 
aura:component implements="flexipage:availableForAllPageTypes,force:appHostable" controller="LightningBingoBoardCreatedAuraClass">
<aura:attribute name="BoardClass" type="LightningArrayWraperClass[]">    </aura:attribute>

    <aura:attribute name="chosenValues" type="String[]">    </aura:attribute>

   <aura:iteration items="{!v.BoardClass}" var="item">
        <lightning:layout horizontalAlign="space">

                   <aura:iteration items="{!item.arrayClass}" var="inneritem">
                    
                       
       <lightning:layoutItem flexibility="auto" padding="around-small">
       <div aura:id="{!inneritem.value}">
           <lightning:button variant="neutral" label="{!inneritem.value}" onclick="{! c.buttonClickEventFire }" />
                       </div>
       </lightning:layoutItem>
                       
       </aura:iteration> 
       </lightning:layout>
 <lightning:button variant="neutral" label="clear all" onclick="{!c.buttonClear}"/>

Basically there are 25 buttons with unique labels to it. I just want to disable the button based on the value entered in a text box which matches the button label. I just want to know how to get all the buttons present inside the component from js controller code
 
buttonClear:function(component,event,helper)
    {
                var button = component.find({ instancesOf : "ui:button" });
    button.set("v.label", "test");
        alert(button);
     var com=component.get("v.LightningArrayWraperClass.BoardClass");
   
}
/*   var button = component.find({ instancesOf : "ui:button" }); this code didnt work ,the button was always null

Any help is greatly welcomed.

Thanks and Regards,
Shiva RV
Hello ,

I have a controller  with one variable in it.When the command button is clicked . js function is called which alert the apex controller variable. The command button increments the variable of apex, but the js always alerts the value set in the apex controller constructor value. No idea why? Do i miss any basic feature of salesforce inregard with accessing variable of apex in js?

Vf page :
 
<apex:page controller="ReRenderIssueController_CC">
    <script>
    function clickButton()
    {
        var s="{!JSENCODE(Stringii)}";
        alert("hello "+{!Stringii} +"  " +{!ii});
        alert(s);
        }
    </script>
    <apex:form>
    <apex:outputPanel id="iiComp">
    {!ii}
       </apex:outputPanel> 
        <apex:commandButton onclick="clickButton();" value="Save" action="{!save}" reRender="iiComp" title="click to reRender"/>
    
    </apex:form>
</apex:page>



Controller 
 
public class ReRenderIssueController_CC {
    public integer ii{get;set;}
    public String Stringii{set;}
    
    public String getStringii()
    {
        return String.valueOf(ii);
        
    }
    
    public ReRenderIssueController_CC()
    {
        ii=2;
        
    }
    
    public pageReference save()
    {
        ii++;
        return null;
           
    }
    
}
I always get value 2,2 in js while the vf page gets changed to 2,3 and so on, based on user click on the button.

Any help will be welcomed.

Thanks and Regards,
Shiva RV

 
I have tried the Build a Discount Calculator traillhead.I followed the steps as given in the trailhead. I got the below error.

Challenge Not yet complete... here's what's wrong: 
There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: WUNARPLY
So i did the same steps again in a new trailhead org but still got the same above mentioned error with different error id. Want to know how to find a solution to this in trailhead?
 
I just want a clarity on transaction in salesforce. I want answers for the following questions :
1 : Suppose i have a vf page , so according to salesforce all that's happening on this page is considered as one transaction?
2 : Unless i have loaded a new vf page ,every per transaction limit is valid for the same vf page?
3 : If till loading a new vf page is considered as transaction and the per transaction limit is valid ,then can i reload the page to avoid per transaction limitation?
4 : If a user has 2 buttons , onclick of it an soql and dml query is made , then if the user clicks the button for 150 times ,then soql exception will happen? and will all those are taken as a single transaction? I mean then all changes would get rolled back?

please do clarify me on those topics.

Thanks and Regards,
Shiva RV  
A user can have up to 50 query cursors open at a time. For example, if 50 cursors are open and a client application still
logged in as the same user attempts to open a new one, the oldest of the 50 cursors is released. Note that this limit is
different for the batch Apex start method, which can have up to five query cursors open at a time per user. The other
batch Apex methods have the higher limit of 50 cursors ? Cursor limits for different Database.com features are tracked separately. For example, you can have 50 Apex query cursors and 50 batch cursors open at the same time.
what does cursor in here means ?? Does it represents the soql query which means i can't make more than 50 soql query inside execute method each time?
Also what does 50 apex query curssor and 50 batch cursor open mean by exactly?
Thanks and Regards,
Shiva RV
I want to know if this is possible in salesforce.Lets say i have an formula field and validation rule in account object. 
I want to know if based on certain condition i can modify another field inside the formula field or validation rule.
Like if (name=='drug')
 isValidRecord=false;
If user enters name as drug on account object,then on insertion the isValidRecord checkbox should be checked using validation rule or formula field.Is it possible using these?
Thanks and Regards,
Shiva RV
 
I want to know about the preparation and skills required to clear the platform developer 2 certification in salesforce. I'm 2 years experienced in salesforce.

Thanks and Regards,
Shiva RV
I have two orgs org1 and org2 . i want to create a vf page and controller in org1 which will display all the accounts present in org2 , let me know how it is possible?

Thanks and Regards,
Shiva RV
The js code that call the apex function is 
function validate()
{
    //  alert("here");
     username=j$('[id$=email]').val();
    
        alert("here ");

    password=j$('[id$=pass]').val();
    // alert(username + "  " +password);
    
 if((username=='') || (password==''))
     {
      document.getElementById("hello").innerHTML="username or password is null";
      return false;   
         }
             
  
   var result= apiToolKitToGetAllCustUser();
    if(result==1)
        {
  alert("in result 1");
            pageRedirectAF(2); // it is the vf actionFunction
             
         }   
            return false;
    }

The vf page code is as follows
 
<button type="submit" class="btn btn-default" onclick="return validate();">login</button>
      <apex:actionFunction action="{!pageRedirectFn}" name="pageRedirectAF">
            <apex:param name="pageData" id="pageData" value="3" assignTo="{!pageData}"/>

     </apex:actionFunction>

Apex Code is as follows :
 
public class custLogin_CC {
    
    public String username{get;set;}
    public String password{get;set;}
    List<CustomUser__c> allUsers{get;set;}
    public Integer pageData{get;set;}
    
    public custLogin_CC()
    {
        
        allUsers=[select Mid__c,password__c,userEmail__c,userName__c from CustomUser__c];
        //pageData=2; if i uncomment this ,it works strangely
        
        
    }
    
    public PageReference pageRedirectFn()
    {
                PageReference pg=null;
           String s= system.CurrentPageReference().getParameters().get('pageData');
                System.debug('pageredirect function called '+ pageData +'   ss ' + s);

        if(pageData==1)
                        pg=new PageReference('/apex/IF_AllQuestionPage_Vf');
        else
                                    pg=new PageReference('/apex/IF_createQuestion_Vf');

        return pg;
        

            
    }
}

Inside constructor in apex class , at line number 12 , if i uncomment the code , the pageData is always 2 at  the pageRedirectFn function. If i comment that line ,then things are working fine.IThe value i pass through the js is auto assigned to the pageData. I want to know if pageData(ie the param variable in vf) shouldn't be initialised if used in param?
I just need to know why it behaves in this way?

Thanks and Regards,
Shiva RV

 
I used a standard list controller for account object . There are around 500 records in the db. But on the page i found only 20 records . i need to know why only 20 records is shown at the page, Also the code worked when i used custom controller. I shall attach the code i used below
<apex:page standardController="account" recordSetVar="acc" >
        <apex:panelGrid columns="5" id="theGrid">

    <apex:repeat value="{!acc}" var="a">
        {!a.id}    <br/>
        {!a.name}
      
    </apex:repeat>
    </apex:panelGrid>
</apex:page>


 
i have a custom login page . How can i align to look like salesforce login ?
<apex:page controller="custLogin_CC" showHeader="false" sidebar="false"> 
    
    <apex:form >
    <apex:pageblock >
        <apex:pageBlockSection >
               username : <apex:inputText value="{!username}"/>
              </apex:pageBlockSection>
        <apex:pageBlockSection > 
        <br/>
            password : <apex:inputSecret value="{!password}"> </apex:inputSecret>
        
       </apex:pageBlockSection> 
       
       
            
        
        <apex:commandButton action="{!login}" value="login" style="float:centre" />
      </apex:pageblock>  
    </apex:form>
</apex:page>
User-added image
What should i do to display label and inputfield together in salesforce?
Thanks and Regards,
Shiva RV
 
It is inregard with the Recruitment , i have 3 object , Position ,Employee website and Job Posting ,where Job Posting is a junction object of Position  and Employee website. I want to know how to make Position object to have a related list of Employee website . i tried to change the layout on position object and found that Employee website is not at all comming on the related list category. Let me know what i have to do to make it possible.

Note :
Position has no relation with Employee website
Job Posting is junction object between Postion and Employee Website
Hi Everyone,
I have followed the procedure to access the rest api by registering app in  https://apps.dev.microsoft.com . But when i'm making a callout for oauth authorize using the following url 
https://login.microsoftonline.com/common/oauth2/v2.0/authorize?response_type=code&client_id=32613fc5-e7ac-4894-ac94-fbc39c9f3e4a&redirect_uri=https:%2f%2foauthplay.azurewebsites.net%2f&scope=openid+offline_access+profile+https:%2f%2foutlook.office.com%2fmail.readwrite+https:%2f%2foutlook.office.com%2fmail.readwrite.shared+https:%2f%2foutlook.office.com%2fmail.send+https:%2f%2foutlook.office.com%2fmail.send.shared+https:%2f%2foutlook.office.com%2fcalendars.readwrite+https:%2f%2foutlook.office.com%2fcalendars.readwrite.shared+https:%2f%2foutlook.office.com%2fcontacts.readwrite+https:%2f%2foutlook.office.com%2ftasks.readwrite

I'm getting status code as 200 instead of 302.Also at further notice , response.getBody() is returning html rather json , also the same get method code work's if i used in browser.
Http http1 = new Http();
        HttpRequest request1 = new HttpRequest();
request1.setEndpoint('https://login.microsoftonline.com/common/oauth2/v2.0/authorize?response_type=code&client_id=32613fc5-e7ac-4894-ac94-fbc39c9f3e4a&redirect_uri=https:%2f%2foauthplay.azurewebsites.net%2f&scope=openid+offline_access+profile+https:%2f%2foutlook.office.com%2fmail.readwrite+https:%2f%2foutlook.office.com%2fmail.readwrite.shared+https:%2f%2foutlook.office.com%2fmail.send+https:%2f%2foutlook.office.com%2fmail.send.shared+https:%2f%2foutlook.office.com%2fcalendars.readwrite+https:%2f%2foutlook.office.com%2fcalendars.readwrite.shared+https:%2f%2foutlook.office.com%2fcontacts.readwrite+https:%2f%2foutlook.office.com%2ftasks.readwrite');
  request1.setMethod('GET');
  HttpResponse response = http1.send(request1);

        System.debug('****'+response.getBody()   );
        System.debug('****  '+response.getStatusCode() );

Please help me with links and solutions
Thanks and Regards,
Shiva RV

 
The salesforce if it involves too much coding ,then i noticed lot of complexities in the code whenever the salesforce updates some of its featues, i would like to know why would someone go for hardcore customization in salesforce instead of choosing  java and heroku? In this case ,their are quite a lot of advantages like
1: no limits as in salesforce
2: licenses are cheap so if the user count is high , it will profitable in the long run
3: No need to have dependency on the existing functionality which may mess with the functionality required.( i have personally been through this, where an existing functionality completely complicated the custom development required)
4: And also need not concern the code breaking because of any standard functionality changes in salesforce ( i have been through this when creating the dynamic thread id in salesforce ,it crashes at some time and no guarante will it work later)

Do share your thoughts to it.

Thanks and Regards,
Shiva RV
Hi All,

is it possible to upload Files to Asset Library from external web services using salesforce REST API?

Thanks.
Hi All,

I have a mobile app(not a salesforce app) which is connected to Salesforce.com and salesforce.com talks to an external website(fulfillment portal) using HTTP REST Request and Response method call out ,now problem is whenever user who wishes to buy a new phone enters his/her details like name,phone model name and his phone number from app and visits physical store outlet for fulfillment,the store representative unable to search the customer data in fulfillment portal..So the store has to manually re-enter customer details.

Integration apex class has been exposed as a WebService
 
public class HttpIntegration{

public String getCalloutResponseContents(String url){

Http h = new Http();

HttpRequest req = new HttpRequest();
req.setEndpoint(url);
req.setMethod('GET');

HttpResponse res = h.send(req);
return res.getBody();


}



 }

While manually testing from Salesforce ,we get a success response from external website(fulfillment portal) and Trigger is also created at Salesforce end to update the Token id at the Order custom object ,but still when the customer goes to store he is unable to find his details,

What can be the possible solution to fix this?

Thanks,
Carolyn
Hi,
I have created 2 process builders on the same object Opportunity say PB1 and PB2. PB2 is getting called from the PB1.

Configurations done on PB1 (Point 1 and Point 2)
1. In PB1 I have selected the ActionType as Processes and Selected PB2 in Processes. PFB the screenshot.
This image is not available because: You don’t have the privileges to see it, or it has been removed from the system


2. In Set Process Variables section I have set only one parameter that is SObject as mentioned in the screenshot below.
This image is not available because: You don’t have the privileges to see it, or it has been removed from the system

On clicking the value a new pop up came I have selected the first option that is
Select the Opportunity record that started this process

Facing problem in PB2(the called Process Builder)

1. Advanced Section is not appearing while setting up the criteria.
This image is not available because: You don’t have the privileges to see it, or it has been removed from the system2. 
Unable to schedule any action from PB2.

Question is whether any action can be scheduled in the sub process builder?


Rgds,
Vai
I have a visual force page as a hyperlink on account details page. I would like to display information about contracts related to that particalar account through the page. There is a catch through, users accessing the page does not have access to contract object, so I built a rest call to call the page as me everytime they try to access the page. I checked the debug logs, contract details are being pulled in, but are all the user can see is blank spaces on vf page. I am posting my code, please let me know what I am doing wrong. 

Vf page:
<apex:page standardController="Account" extensions="ContractdetailsfromaccountController" >
    
    <apex:outputPanel >
        <div style="float:Left;margin-top:2em;font-family:  sans-serif;font-size:12px;/*width:50%;*/">
            <b>Account Name: {!Account[0].Name}<br/>
                Account Phone: {!Account[0].Phone}</b><br/>
                <apex:outputPanel rendered="{!!error}">
            <b>Contact: {!contracts[0].Welcome_Letter_Recipient__r.Name}</b><br/>
            </apex:outputPanel>
        </div>
    </apex:outputPanel>
    <br/><br/><br/><br/><br/><br/>
    <apex:outputPanel rendered="{!error}">
            <td style="font-family:  sans-serif;font-size:30px;padding-left: 0.6em;padding-right: 0.6em;"><b>This Account Does not have any contracts linked to it. </b></td>
    </apex:outputPanel>
    <br/><br/>
    <apex:outputPanel rendered="{!!error}">
    <apex:form >
    <apex:commandLink styleclass="start" target="_blank" onclick="window.open('/apex/Contractdetailsfromaccount', 'width=300, height=250' return false;"/>
    <apex:pageblock > 
        <apex:repeat value="{!contracts}" var="con" id="therepeat">
            <apex:pageBlockSection title="Contract Details" collapsible="false" columns="2" >
                <apex:outputText label="Contract Number" value="{!con.Name}"/>
                <apex:outputText value="{!con.cllease__Lease_Status__c}"/>
                <apex:outputText label="Funded Amount" value="{0}{1, number, ###,##0.00}"><apex:param value="$"/><apex:param value="{!con.cllease__Lease_Receivable_Amount__c}"/></apex:outputText>
                <apex:outputText label="Opportunity Owner" value="{!con.Opportunity_Owner_Sales_Rep__c}"/>
                <apex:outputText label="Payment Amount" value="{0}{1, number, ###,##0.00}"><apex:param value="$"/><apex:param value="{!con.cllease__Payment_Amount__c}"/></apex:outputText>
                <apex:outputText label="Channel" value="{!con.Sales_Channel__c}"/>
                <apex:outputText label="Total Due Amount" value="{0}{1, number, ###,##0.00}"><apex:param value="$"/><apex:param value="{!con.cllease__Amount_to_Current__c}"/></apex:outputText>
                <apex:outputText value="{!con.cllease__Term__c}"/>
                <apex:InputCheckbox value="{!con.Ever_Delinquent__c}" disabled="true"/>
                <apex:outputText label="Start Date" value="{0,date,MM'/'dd'/'yyyy}"><apex:param value="{!con.cllease__Commencement_Date__c}"/></apex:outputText>
                <apex:outputText label="Delinquent Amount" value="{0}{1, number, ###,##0.00}"><apex:param value="$"/><apex:param value="{!con.cllease__Delinquent_Amount__c}"/></apex:outputText>
            	<apex:outputText label="End Date"  value="{0,date,MM'/'dd'/'yyyy}"><apex:param value="{!con.cllease__Maturity_Date__c}"/></apex:outputText>
                <apex:outputText label="Delinquent Days" value="{!con.cllease__Days_Past_Due__c}"/>
                <apex:outputText label="Next Due Date" value="{0,date,MM'/'dd'/'yyyy}"><apex:param value="{!con.cllease__Next_Due_Date__c}"/></apex:outputText>
                <apex:outputText label="Outstanding Bills" value="{!con.cllease__Dues_Details__r.size}"/>
                <apex:outputText label="Gross Yield" value="{0, number, ###,##0.00}{1}"><apex:param value="{!con.Gross_Yield__c}"/><apex:param value="%"/></apex:outputText>
                <apex:outputText value="{!con.Pre_Payment_Option__c}"/>
                <apex:outputText label="Net Yield" value="{0, number, ###,##0.00}{1}"><apex:param value="{!con.Net_Yield__c}"/><apex:param value="%"/></apex:outputText>
                <apex:InputCheckbox value="{!con.Early_Buyout_Option__c}" disabled="true"/>
                <apex:InputCheckbox label="Set up on ACH?" value="{!con.ACH_Configured__c}" disabled="true"/>
                <apex:outputText value="{!con.Same_as_Cash_Option__c}"/>
                <apex:outputText label="Pieces of Equipment" value="{!con.cllease__Contract_Equipments__r.size}"/>
                <apex:outputText label="No of Payments Remaining" value="{!con.cllease__Payment_Streams__r.size}"/>
                <!---<apex:InputCheckbox rendered="{!AND(con.cllease__Charges__r !=Null, con.cllease__Charges__r.size>0)}" label="Enrolled in Insurance?" value="{!EPP}" disabled="true"/>
                <apex:InputCheckbox rendered="{!AND(con.cllease__Charges__r !=Null,con.cllease__Charges__r.size=0)}" label="Enrolled in Insurance?" value="{!EPPfalse}" disabled="true"/>--->
                <apex:outputText />
                 <apex:outputText />
                <apex:outputText />
                <!---<apex:outputText label="Insurance Payment Amount" value="${!IF((con.cllease__Charges__r.size>0),con.cllease__Charges__r[0].cllease__Original_Amount__c,0.00)}"/>---> 
                <br/>
         <div style="border: 3px solid #afb3b1;border-radius:0px;background-color:#afb3b1;color:black;width:200%;text-align:Left;font-size:11px;font-family:  sans-serif"><b>Equipment Information</b></div>
        	<apex:repeat value="{!con.cllease__Contract_Equipments__r}" var="Equip">
                <tr>
                 <apex:outputText value="{!Equip.Equipment_Type_Name__c}"/>
                 <apex:outputText value="{!Equip.Equipment_Sub_Type_Name__c}"/>
                 <apex:outputText value="{!Equip.cllease__Total_Dealer_Charges__c}"/>
                 <apex:outputText value="{!Equip.cllease__Make__c}"/>
                 <apex:outputText value="{!Equip.cllease__Equipment_Description__c}"/>
                 <apex:outputText value="{!Equip.cllease__Model__c}"/>
                    <div style="width:200%; height:1px; background:grey;"></div>
                </tr>
         	</apex:repeat>
           </apex:pageBlockSection>
        </apex:repeat>
    </apex:pageblock>
   </apex:form>
    </apex:outputPanel>
</apex:page>

Controller:
public without sharing class ContractdetailsfromaccountController {
    public list<cllease__Lease_Account__c> contracts {get; set;}
    public List<Account> Account {get; set;}
    public boolean error {set; get;}
    public boolean EPP {set; get;}
    public boolean EPPfalse {set; get;}
   
    public ContractdetailsfromaccountController(ApexPages.standardController Acc){
        Account = [select id, Name, Phone from Account where Id =: Acc.getId()];
        
        HttpResponse resp = getRecord();
        if(resp != null && resp.getStatusCode() == 200) {
            System.debug(resp.getBody());
        	contracts = (list<cllease__Lease_Account__c>) JSON.deserialize(resp.getBody(), list<cllease__Lease_Account__c>.class);
        }
        EPP=true;
        EPPfalse =false;
        If(contracts == null || contracts.size()==0){
            error =true;
        }
    }
    public HttpResponse getRecord() {
        Map<String, String> authDetail;
        
        Integration_Details__c cred = Integration_Details__c.getInstance('ContractAccess');
        
        if(cred != null) {
            Blob decryptedData = Crypto.decryptWithManagedIV('AES256', EncodingUtil.base64Decode(cred.Key__c), EncodingUtil.base64Decode(cred.Password__c));
            authDetail = getSessionId(cred.Instance_URL__c, cred.UserName__c, decryptedData.toString());
        } else {
            // error handling
        }
        
        HttpRequest req = new HttpRequest();
        req.setEndpoint(cred.Instance_URL__c+'/services/apexrest/contractDetailsFromAccount/'+Account[0].Id);
        req.setMethod('GET');
        req.setHeader('Authorization', 'OAuth ' + authDetail.get('sessionId'));
        System.debug(req);
        return new Http().send(req);
    }
    
    public Map<String, String> getSessionId(String url, String username, String password) {
        Map<String, String> authDetails;
        String sessionId;
        String email;

        HttpRequest request = new HttpRequest();
        request.setEndpoint(url+'/services/Soap/u/44.0');
        request.setMethod('POST');
        request.setHeader('Content-Type', 'text/xml;charset=UTF-8');
        request.setHeader('SOAPAction', '""');
        // creating soap xml request
        request.setBody('<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"><Header/><Body><login xmlns="urn:partner.soap.sforce.com"><username>'
                        + username + '</username><password>' + password + '</password></login></Body></Envelope>');
		
        HttpResponse resp = new Http().send(request);

        if(resp != null && resp.getStatusCode() == 200) {

        	Dom.Document doc = resp.getBodyDocument();

            sessionId = doc.getRootElement().getChildElement('Body','http://schemas.xmlsoap.org/soap/envelope/').getChildElement('loginResponse','urn:partner.soap.sforce.com')
                .getChildElement('result','urn:partner.soap.sforce.com').getChildElement('sessionId','urn:partner.soap.sforce.com').getText();

            email = doc.getRootElement().getChildElement('Body','http://schemas.xmlsoap.org/soap/envelope/').getChildElement('loginResponse','urn:partner.soap.sforce.com')
                .getChildElement('result','urn:partner.soap.sforce.com').getChildElement('userInfo','urn:partner.soap.sforce.com').getChildElement('userEmail','urn:partner.soap.sforce.com').getText();

            System.debug('sending request as '+email);

            authDetails = new Map<String, String>();
            authDetails.put('sessionId', sessionId);
            authDetails.put('email', email);
        } else {
            System.debug('resp error: '+resp.getBody());
        }

        return authDetails;
    }

}

Api:
@RestResource(urlMapping = '/contractDetailsFromAccount/*')
global class ContractDetailsAPI {
    
    @HttpGET
    global static List<cllease__Lease_Account__c> getContractsFromAccount() {
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        String accId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
        list<cllease__Lease_Account__c> contracts = [select id, name, cllease__Account__c, cllease__Account__r.name,Account_Phone__c, cllease__Lease_Status__c,ACH_Configured__c,
                     cllease__Lease_Receivable_Amount__c,cllease__Commencement_Date__c,cllease__Maturity_Date__c,cllease__Payment_Amount__c,
                     cllease__Next_Due_Date__c,cllease__Amount_to_Current__c,cllease__Delinquent_Amount__c, Net_Yield__c, Gross_Yield__c, cllease__Term__c,
                     Opportunity_Owner_Sales_Rep__c,Sales_Channel__c, cllease__Days_Past_Due__c,Welcome_Letter_Recipient__c,Welcome_Letter_Recipient__r.Name,
                     Early_Buyout_Option__c,Pre_Payment_Option__c,Same_as_Cash_Option__c,Ever_Delinquent__c,
                     (select id, cllease__Payment_Satisfied__c from cllease__Dues_Details__r where cllease__Payment_Satisfied__c=false),
                     (select id, cllease__Billed__c, cllease__Active__c from cllease__Payment_Streams__r where cllease__Billed__c=false and cllease__Active__c=true),
                     (select id, cllease__Fee_Definition__c, cllease__Fee_Definition__r.Name, cllease__Original_Amount__c from cllease__Charges__r 
                      where cllease__Fee_Definition__r.Name='Equipment Protection Program'),
                     (select id, cllease__Equipment_Cost__c, Equipment_Type_Name__c, Equipment_Sub_Type_Name__c,
                      cllease__Equipment_Description__c, cllease__Model__c, cllease__Make__c,cllease__Equipment_Serial_Number__c, cllease__Total_Dealer_Charges__c
                      from cllease__Contract_Equipments__r order by cllease__Equipment_Cost__c DESC)
                     from cllease__Lease_Account__c where cllease__Account__c =: accId and cllease__Lease_Status__c !='PARTIAL APPLICATION' order by createddate DESC];
       
        return contracts;
    }
}

Would really appreciate any help in this.

Thanks,
​​​​​​​Krishna Vegiraju
<apex:page>

   <script>     
    function errorHandling()
    {
        alert('clicked save');
        alert(document.getElementById('{!$Component.fm:pb:sectionQty:pbsQ:dateQ}'));
        var validate=document.getElementById('{!$Component.fm:pb:sectionQty:pbsQ:dateQ}').value; 
        
        if(validate == '')
        {
            alert('please enter the Name');
            // return false;
        }    
        else
        {
           alert('else');
            save();
            
        }       
    }    
    </script>

    <apex:form rendered="{!!recordsTable}" id="fm" >      
        <apex:actionFunction name="save" action="{!save}"  />

        <apex:pageBlock rendered="{!!recordsTable}" id="pb">                    
            <div id="sectionQty">                
                <apex:pageBlockSection title="Establish Quantity Schedule" collapsible="false" columns="1" id="pbsQ" >
                    <apex:input label="Start Date" type="date" value="{!datefieldQty}" id="dateQ" /> 
                </apex:pageBlockSection>  
            </div>          
            
            <apex:pageBlockButtons location="bottom" >                 
                <apex:commandButton value="Save" onclick="errorHandling();return false;" />  
            </apex:pageBlockButtons>            
        </apex:pageBlock>          
    </apex:form>
  </apex:page>
I want to understand if a batch class with 1million records are run , will it executes 200 records per batch after batch? I mean by , at any point of time only 1 batch of records are executed? or is it like n number of batches of records can run parallelly too?
Want to understand if only 1 batch of records will be locked at any given records or it can be more.
Thanks,
Shiva RV
  I want to determine the next business day if a service request is submitted on a weekend.
example: If I submit a service request on a weekend (Saturday/Sunday). The actual date received should be a Monday (which is the business day not Sunday or Saturday). Now if Monday is a holiday, I want the next business day to be the actual date.

I will store this in a different field. I will still keep track of the actual date the service was requested ( Received Date) and populate Business Day with the right date using the formula.

I don't want to use Apex if possible i want to use formulas. We already know the list of Holidays for a calendar year and it is same every other year. The only issue is when a national holiday falls on a weekend (USA) obviously the Monday becomes a holiday. I wonder how it can be handled.

If you have apex solutions too i am willing to hear you out
ery new to Triggers and hoping this is a simple replacement of text in the code we already have working in the Account object that was built when we had a Dev support.

What I'm trying to do is make my trigger that I already have work the same way but for cases. When we build Cases we relate it to the account via a lookup and that then brings in the Account Manager, what we need to happen is that whenever the account manager creates either a New task, New Event, Log a call, Mail Merge, or Send an Email it updates the "Last Activity Date" field in the Account object. Here's the Triggers I have for tasks and events:

public class TaskTriggerHandler {
    public static void updateAccountLastActivityDate(){
        List<Task> tskList = (Task[])Trigger.New;
    Set<Id> tskIds = new Set<Id>();
    List<Account> accountsToUpdate = new List<Account>();
    for(Task tsk : tskList){
        system.debug('Account id '+tsk.AccountId);
            tskIds.add(tsk.AccountId);
    }
    List<Account> accList= [Select id,Account_Manager__c,Last_Activity_Date__c,Account_Status__c  from Account where id IN :tskIds];
        system.debug('accList: '+accList);
    if(accList.size() > 0){
        for(Account acc : accList){
            if(acc.Account_Manager__c == UserInfo.getUserId() && acc.Account_Status__c == 'Active' || Test.isRunningTest()){
               acc.Last_Activity_Date__c = Date.today();
              accountsToUpdate.add(acc);   
            }
        }    
    }
    if(accountsToUpdate.size() > 0){
        update accountsToUpdate;
    }
    }
}

public class EventTriggerHandler {
    public static void updateAccountLastActivityDate(){
    List<Event> evtList = (Event[])Trigger.New;
    Set<Id> evtIds = new Set<Id>();
    List<Account> accountsToUpdate = new List<Account>();
    for(Event evt : evtList){
        
        evtIds.add(evt.AccountId);
    }
    List<Account> accList= [Select id,Account_Manager__c,Last_Activity_Date__c,Account_Status__c  from Account where id IN :evtIds];
    if(accList.size() > 0){
        for(Account acc : accList){
            if(acc.Account_Manager__c == UserInfo.getUserId() && acc.Account_Status__c == 'Active' || Test.isRunningTest()){
                acc.Last_Activity_Date__c = Date.today();
                accountsToUpdate.add(acc);
            }
        }    
    }
    if(accountsToUpdate.size() > 0){
        update accountsToUpdate;
    }
    }
}
Hi All,

I want to know the basic resons for below point:

1.can we call future method into batch apex,if not why??
2.can we call futute method into anothrt future method??
We need a freelance SF developer that can develop and implement our lead to quote process. Travel Industry experience is a plus. We have existing data schema and workflow mapping. etc. Developer must be proficient in Force.com pages, web to lead Apex, Visual Force, IDE, migration tools, Web Services, third party API Integration. This is the first phase of our project. We are looking to develop an ongoing relationship with a freelance developer.
  • October 20, 2010
  • Like
  • 0
Hi.
I have big Visualforce page, and now I tried to use insertRow / insertCell to make dynamic table.

First of all, I tested it on test table.
I made button that call make row function.

However, whenever I click button, the new row appears, and dissapear soon. for 0.2~0.3sec.

Why do this dissapear? How do I avoid it?

Please help.