• 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,

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.