• v varaprasad
  • PRO
  • 3827 Points
  • Member since 2015
  • Salesforce Developer

  • Chatter
    Feed
  • 122
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 15
    Questions
  • 843
    Replies
There is an issue with my HTTP request.salesforce is not allowing me to use PATCH method.
Below are the notification which i get after calling a patch.

System.CalloutException: Invalid HTTP method: PATCH.

when we override the method with patch
req.setHeader('X-HTTP-Method-Override','PATCH');
req.setMethod('POST');
Then i am geeting below notification.
System.HttpResponse[Status=Method Not Allowed, StatusCode=405]
Can somebody help me here I am getting the error while getting data based on id which I am passing, I am able to generate session id as well.

Salesforce to Salesforce Rest Api Integration.

My code is,

public class restApiClassSalesforceorg1{


private string cKey='XXXXXX';
private string cSecret='XXXXXX';
private string uName='XXXXXX';
private string passwd='XXXXXX';

// Above information is hided


public class responseWrapper{

public string id;
public string access_token;
public string instance_url;

}

public string getRequestToken()
{
string reqBody='grant_type=password&client_id='+cKey+'&client_secret='+cSecret+'&username='+uName+'&password='+passwd;                                      

Http h=new Http();
HttpRequest req=new HttpRequest();
req.setBody(reqBody);
req.setMethod('POST');
req.setEndpoint('https://login.salesforce.com/services/oauth2/token');

HttpResponse hresp=h.send(req);
responseWrapper wResp=(responseWrapper)JSON.deserialize(hresp.getBody(),responseWrapper.class);
system.debug('Instance url'+wResp.instance_url);
system.debug('session id'+wResp.access_token);
return wResp.access_token;


}

public static list<Account> getConList()
{
list<account> accList1=new list<account>();
String accToken;
string ExternalId='SomeIDfromOtherOrg';
string responseBody;
string endPoint='https://ap5.salesforce.com/services/apexrest/v1/getAccountOnExternalId/' + ExternalId;
restApiClassSalesforceorg1 obj=new restApiClassSalesforceorg1();
accToken=obj.getRequestToken();
system.debug('access token'+ accToken);
if(accToken!='')
{
Http h1=new Http();
HttpRequest req1=new HttpRequest();
req1.setHeader('Authorization','Bearer'+accToken);
req1.setHeader('Content-Type','application/json');
//req1.setHeader('Accept','application/json');
req1.setMethod('GET');
req1.setEndpoint(endPoint);
HttpResponse hresp1=h1.send(req1);
responseBody=hresp1.getBody();
JSONParser parser=JSON.createParser(responseBody);
 while (parser.nextToken() != null) {
 Account obj1=new Account();
 if ((parser.getCurrentToken() == JSONToken.FIELD_NAME) && (parser.getText() == 'Name')) {
 
 string accName=parser.getText();
 obj1.name=accName;
 
 }
accList1.add(obj1);
}
}
return accList1;

}



}

Code from other org,

@RestResource(urlMapping='/v1/getAccountOnExternalId/*')
   global with sharing class getAccount {
     @Httpget
      global static list<Account> fetchAccount(){
        RestRequest req = RestContext.request;
        RestResponse res = Restcontext.response;
        string accId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
        list<Account> lstAcc=[Select id , name,ExternalIdForAccount__c from Account where Id=:accId ];
        
        return lstAcc;
      }
   }


 
Hello,

When somone gives a swagger, What else do we need to do to do testing in Postman.

is there any authentcation key i should ask ?

I imported the swagger and i directly clicked on send
I get below error
{
    "code": "500",
    "name": "Internal Gateway Error",
    "message": "error unknown
}
 
Hi,

I am starting my salesforce lightning component framework superbadge and I have written the below code. I am using the component in a lightning app and using the preview for testing. Can you please let me know why the dropdown menu and buttons are not aligned properly.

Code

<aura:component >
    <aura:attribute name="attr_selectTypeBoat" type='String[]' default='All Types'/>
    <lightning:layout horizontalAlign="center">
            <lightning:layoutItem flexibility="auto" padding="around-small" >
                <lightning:select aura:id="selectTypeBoat" name="selectType" label='Please select'>
                    <aura:iteration items='{!v.attr_selectTypeBoat}' var='option'>
                        <option value='{!option}' text='{!option}' />
                    </aura:iteration>
                </lightning:select>
            </lightning:layoutItem>
            <lightning:layoutItem flexibility="auto" padding="around-small" >
                <lightning:button label="Search" variant="brand"/>
            </lightning:layoutItem>
            <lightning:layoutItem flexibility="auto" padding="around-small">
                <lightning:button label="New" variant="neutral"/>
            </lightning:layoutItem>
        </lightning:layout>
</aura:component>

Output

User-added image

Thanks
Vinny
 
HI Guys.

Looking for some help writing  a test class. Very basic, just record creation.

Visualforce page is basic, just standard controller Account.

 
public class AccExtension4 {

private final Account objacc;


    public AccExtension4(ApexPages.StandardController controller) {
         this.objacc=(Account)controller.getrecord();
    }
    
     public Account acc {get; set;}
     public Opportunity opp {get; set;} 
     Account cust = new Account();   
     Opportunity opps = new Opportunity();


public PageReference Save() {


       //Add all the class information then insert the class
        cust.LastName= objacc.LastName;
        cust.FirstName= objacc.FirstName;
        cust.Phone= objacc.Phone; 
        cust.PersonMobilePhone= objacc.PersonMobilePhone; 
        cust.PersonEmail= objacc.PersonEmail;          
        cust.Siebel_References__c = objacc.Siebel_References__c ;           
        cust.Customer_Row_ID__c = objacc.Customer_Row_ID__c;           
        cust.RecordTypeid = '0120E000000aznK';
        upsert cust Customer_Row_ID__c;
    
    
         opps.AccountId = cust.id;
         opps.Name = 'New Sale';
         opps.Product_Name_String__c = objacc.Product_Names__c;
         opps.CloseDate = system.today();
         opps.RecordTypeID = '012200000000re7';
         opps.Customer_Type__c = 'Fixed';
         opps.Call_Reason__c = 'Non Retention';  
         opps.Call_Reason_Detail__c = objacc.Call_Reason_Detail__c;      
         opps.StageName = 'Closed Won';    
         opps.PriceBook2Id = '01sD0000000d3L2';                 
         opps.Retention_Promotions_Offered_V2__c = objacc.Promotions_Offered__c;                       
         insert opps;
 
 
return new PageReference('/'+ opps.id); 
         
         }

    }


I had a look online for an example to use.
This is what has given me a low code coverage.
@isTest 
public class AccExtension2Test 
{
 static testMethod void testMethod1() 
 {
 Account testAccount = new Account();
        testAccount.LastName= 'test last name';
        testAccount.FirstName= 'test first name';
        testAccount.Phone= '021000000'; 
        testAccount.PersonMobilePhone= '021000000'; 
        testAccount.PersonEmail= 'nihan@gmail.com';          
        testAccount.Siebel_References__c = 'tester' ;           
        testAccount.Siebel_Customer_Row_ID__c = '32pkj-32nm';           
        testAccount.RecordTypeid = '012D00000003KdL';
        upsert testAccount Siebel_Customer_Row_ID__c ;



 Test.StartTest(); 
  ApexPages.StandardController sc = new ApexPages.StandardController(testAccount);
  AccExtension4 testAccPlan = new AccExtension4(sc);

  PageReference pageRef = Page.FibreSimplex; // Add your VF page Name here
  pageRef.getParameters().put('id', String.valueOf(testAccount.Id));
  Test.setCurrentPage(pageRef);

  //testAccPlan.save(); call all your function here
 Test.StopTest();
 }
}

 
Hi,
We have a third party app that requires me to expose certain data in Salesforce (person account object) through their API. They already have one built, just need me to expose the correct data. How would I go about doing this? 

Any help is much appreciated!
Many Thanks,
Natasha 

 
Hi,
I have written the apex class for addition of two numbers. but for writing the test class i have issue.
Program is
--------------
public class Add 
{    
public integer a;
public integer b;
public integer c;
public integer addt()
{
    c=a+b; 
    system.debug('the result is'+c);
    return c;
}      
}

My test class
-----------------
@istest
public class Addtest
{
static testmethod void testadd()
{
    Add ad=new Add();
    integer res=ad.addt();
    system.assertEquals(res);
}
}
the test class is throwing error as
"Method does not exist or incorrect signature: void assertEquals(Integer) from the type System"

Any guidance please

Thanks in advance.
Hello folks , 
Requirement:  Can any one tell me how to write a trigger on contact to check the duplicates for Name , phone , email . if any duplicate arises we need to put error message . condition is (Name OR phone OR Email).

trigger DuplicateTwoFieldsContact on Contact (before insert,before update) 
{
 if(trigger.isBefore)
 {
  map<String,Contact> mapcontact = new map<String,Contact>();
   map<String,Contact> phonemap = new map<String,Contact>();
  
  for(contact con: trigger.new) 
   {
   if(                                                 
   ((con.Email != null) && (Trigger.isInsert || con.email != trigger.oldmap.get(con.id).email )) ||
    ((con.Phone != null) && (Trigger.isInsert || con.Phone != trigger.oldmap.get(con.id).Phone ))
    )
     {                                
     if( !mapcontact.containskey(con.Email) || !phonemap.containskey(con.Phone))
      {
      mapcontact.put(con.Email ,con);
      phonemap.put(con.Phone ,con);
      
      } 
     }
   }
 
 for(contact c:[select id ,Email ,Phone from contact where Email =: mapcontact.keyset() OR Phone =: phonemap.keyset() ])
 {
 contact newcontact = mapcontact.get(c.Email);
  newcontact.Email.adderror('Duplicate Email has been detected ');
 
 contact Phonecontact = phonemap.get(c.Phone);
  Phonecontact.Phone.adderror('Duplicate Phone has been detected ');
 
 }
 }
}

Hi,

I would lik to query all validation rules that contain a condition with profiles. Is this possible?

Thanks in advance!

I'm trying to write a class that will call a flow. I don't understand why Dev Console won't let me save, telling me that myFlow.start() is an invalid constructor name.
User-added image
Hi, 

I have a list with the following format in apex controller. 

Custom__Object_Analysis__c:{Id=a0L1N00000L1izqUAB, Name=All Accounts, CreatedDate=2018-02-15 15:15:12, isCustom__c=false, Fields__c=0, Filter__c=Industry = '', Object_Name__c=account, Tally__c=0}

How do I serialize this? 
JSON.Serialize() gives Uncaught SyntaxError: Unexpected string 
Hi,

I have created a simple Rest API endpoint however my test class is not touching the endpoint at all. The API URL mapping is

//** services/apexrest/accounts/0016E00000YNC49/entitlements
@RestResource(urlMapping='/accounts/*/entitlements')
Global with sharing class U4_REST_AccountEntitlements {
    @HttpGet
    global static Account getAccount(){

and returns entitlement values. Using REST Explorer within workbench it works perfectly but when I run the test class it is not returning any values. In fact ... the result is [REST_AccountEntitlements_TEST].RestResource response:RestResponse:[headers={}, responseBody=null, statusCode=null]​

Any help would be much appreciated.
Test.startTest();

           Id recordId = NewServiceAccount.Id;
           RestRequest request = new RestRequest();
           RestResponse response = new RestResponse();
           request.httpMethod = 'GET';

           Request.requestURI  ='/services/apexrest/accounts/'+NewServiceAccount.Id+'/entitlements';
           System.debug(LoggingLevel.Info,'+*+*+*+*+*+*+* '+NewServiceAccount.id);

           System.debug(LoggingLevel.Info,'[REST_AccountEntitlements_TEST].RestResource response:'+Request.requestURI);

           RestContext.request = request;
           RestContext.response = response;

           System.debug(LoggingLevel.Info,'[REST_AccountEntitlements_TEST].RestResource response:'+response); 
  
        Test.stopTest();

 
I have tried this :
trigger Surajtrg on Contact (after insert, after update, after delete)
{
    set<id> act=new set<id>();
    List <Account> lstAccountsToUpdate = new List <Account>();
    if(trigger.isInsert ||trigger.isUpdate)
    {
        for(contact cc:trigger.new)
        {
            act.add(cc.AccountId);
         }
    }
    if(trigger.isDelete)
    {
        for(contact cc:trigger.old)
        {
            act.add(cc.AccountId);
        }
    }
    List<Account> shocksList = [SELECT Id,Youngest__c,(SELECT id,MIN(Age__c) FROM Contact) from Account where Id IN: act]; 
for(Account acc:shocksList) //(Select Id from Contacts)  represents size of Contacts        
{
    Account accObj = new Account ();
    accObj.Id = acc.Id;
   accObj.Youngest__c= acc.MIN(Age__c);
    lstAccountsToUpdate.add(accObj);
}
    Update lstAccountsToUpdate; 
}
 
I have multiple contacts with their different ages. I want to fetch out minimum and max age among all contacts. 
I tried this query....Select id,Min(age__c) from Contact GROUP BY Name.
please correct me
Hi everyone, 

I'm a new developer so please bear that in mind! I'm trying to update an Account's custom fields from a Custom Object called Pub_Opportunity__c. The account has a lookup relationship to the pub_opportunity__c. But I only want the Account to update once with these fields as sometimes there are many pub opportunities related to one Account. I just want to retain the original values. 

When I use the code below, it keeps updating the Account every single time with the new Pub Opportunity's fields regardless of the condition. For example, when I change the Account_Status__c field on the Account to 'Active', when I create a new Pub Opportunity, it still updates the Account_Status__c to 'Closed Won - Implementing'. Even when the Link_to_Contract__c field on the Account is filled out, it still updates the field with the new value from the Pub Opportunity. 

Would appreciate your help!


public static void updatePubs(Map<Id,Pub_Opportunity__c> pubOppMap){
        List<Account> aList = new List<Account>();
        
        for(Pub_Opportunity__c p : pubOppMap.values()){
            Account a = new Account();
            if(a.Account_Status__c != 'Active'){
                a.Account_Status__c = 'Closed Won - Implementing';
                a.id = p.Publisher__c;
               if(String.Isblank(a.Link_to_Contract__c)){
                a.Link_To_Contract__c = p.Link_to_Contract__c;
            }
          
            aList.add(a);
        }
        
        if(aList.size() > 0){
            update alist;
        }
    }
    }
    
I am trying to search through all records passed in by trigger and find ones where buyer zip codes matches an open Open Territory. The "Name" field on Open_Territory__c contains zip codes.

I am getting 2 errors. Variable does not exist: Name, and DML requires SObject or SObject list type: List<Id>.

Any help would be appreciated. 
 
public static void setOpenTerritory(List<dealer__Sales_Up__c> triggerValues) {
        List<Open_Territory__c> openList = [SELECT Id, Name FROM Open_Territory__c WHERE Is_Active__c = true];
        List<Id> suToUpdate = new List<Id>();
        System.debug('openList contains ' + openList);
        // Search through all Sales Ups passed in trigger. Find ones with buyer zip codes matches Open Territory zip and add them to List.
        for(dealer__Sales_Up__c s : triggerValues) { 
            if(s.dealer__Mailing_Zip__c === openList.Name){
                s.Open_Territory__c = true;
                suToUpdate.add(s.Id);
            }
        }
        update suToUpdate;
    }

 
On the Case object we have the standard lookup field to the standard Account object. I also added a field called "Login_ID__c". We have this same field (Login_ID__c) in the Account object as well. Now when the user enters a Login ID in the case object, based on the value in the Login ID field it should auto populate the Account lookup field because each Account record has a unique Login ID. I have tried using a workflow and process builder but to no avail. From what I’ve researched, I think it’s possible to do this with an apex trigger but I am not familiar with apex at all. Can anybody help me out or offer any insight? Thank you.
 
WHAT: In my Account object when a field "GDPR flag" gets checked,it should automatically fill the "GDPR date" field to be te same date(date on which the flag chcekbox  gets checked).
So we are using the formula field: IF( R2_ACC_CHK_GDPR_UnSub__c , TODAY() , NULL).
ISSUE: Because of this formula field, the "GDPR date"is getting changed everyday to the current day, which is wrong.It should reflect the day when the checkbox was checked and should stay always the same date.i.e if we marked any customer as GDPR on 09th Sept 2018, tomorrow or one year from now , the date should always reflect 09th sept 2018.
How can i achieve that? Can i make some changes in formula field?or can i do it in the triger code?Please help.I am novice so would require your explanation as well.
 
Hello friends, Iam getting error "Variable does not exist: RecursiveTriggerHandler" while deploying the apex trigger to production.
Please find the trigger below

trigger BD_AccountTrigger on Account (after insert, after update) {
  BD_ProcessSwitchSettings__c custSettings = BD_ProcessSwitchSettings__c.getInstance();
 
 System.debug('****************in BD_LeadTrigger');
 
 if(trigger.isInsert || trigger.isUpdate){
   System.debug('****************in BD_LeadTrigger, Trigger.old:'+trigger.old);
   System.debug('****************in BD_LeadTrigger, Trigger.new:'+trigger.new);
 } 
  
 // if(!custSettings.BD_AllTriggersDisabled__c && custSettings.BD_NotesTriggerEnabled__c){
  if(!custSettings.BD_AllTriggersDisabled__c ){
     if(RecursiveTriggerHandler.isFirstTime){
        RecursiveTriggerHandler.isFirstTime = false;
        new  AC_AccountTriggerHandler().run();
     } 
        
  }
}
Hi All,

How to transfer knowledge articles in different languages with data.

EX: English to Spanish

Thanks in advance...
Hi All,

Please help me on below issue.


1. Trigger will work on user mode or system mode
2. In below class account is having one contact but one user able to see contact another user not why another user not able to see contact please help me.

3. As per my knowledge below class will work on system mode.
4. Please help me why another user not ble to see the contact.
 
trigger sampleTrigger on account(after update){
  AccountHelper.Createcontact(Trigger.new);
}

If account type == hot then i need create one conatct for account only one contact.
If contact is existing then no need to crete contact.

public class AccountHelper{

 public static void Createcontact(list<account> accs){
  set<id> acciDs = new set<id>(); 
  for(account acc : accs){
   if(acc.type == 'hot'){    
      acciDs.add(acc.id);   
   } 
 }
 list<account> accslist = [select id,name,(select id from contacts) from acount];
 
 for(account acc : accslist){
     if(acc.contacts.size()== 0){
	 
	    //crating contact here 
	 }
 
 }
}

 
If anybody aware on deleting territories  can help me  because we could not able to delete territories  even though we had "Managed Territories"  permission in profile level. The  territory  trying to delete don't have child  territory but have parent territory.So while deleting I am getting the following error  below.

Error:  
Cannot Delete the Territory
You cannot delete the territory because at least one territory rolls up to it. 

could you please help on this.
I'm looking for a side gig, about 30 hours a week.

My certficiations: http://certification.salesforce.com/certification-detail-print?conId=003G000002FKbh3IAD

I have about 5 years experience with Salesforce. Please send an email: varaprasad4sfdc@gmail.com email for a resume.

Thanks
Varaprasad
@For Support : varaprasad4sfdc@gmail.com
Some users having issue with list views .
Ex : 

DETAILED DESCRIPTION:
1) select a personalized view (here e.g. 003 - My cases in process).
2) open a case out of this list (here e.g. CAS001).
3) go back to the case list by pressing the "Back-Arrow" of the browser .
 
The wrong list of cases is displayed Here.

Any help really appreciated.

Thanks
Varaprasad
Hi ,

Some times in chatter Chatter bold ,italic buttons are not displaying.
User-added image

Please let me know the reason .

Thanks
Varaprasad
 
Hi I have come across the below error, using JavaScript in Button.

An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. 
If you believe you have additional information that may be of help in reproducing or correcting the error, please contact Salesforce Support.
 Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information.
 We apologize for the inconvenience. 

Thank you again for your patience and assistance. And thanks for using salesforce.com! 

Error ID: 1652772134-27944 (-1092651723)
 
{!REQUIRESCRIPT("/soap/ajax/15.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/15.0/apex.js")}
var r = "{!Opportunity.Opportunity_Product_Count__c}";
var oppid = "{!Opportunity.Id}";
 

if(r == 1 )
{        
                    window.location.href='/apex/VFPageName?id='+oppid;
}
else
{
    alert ("No Products exists !");

Please help me out with alternative solution ASAP
Hi All,

i need to create one validation rule..

User-added image

in each prefernce picklist field i have 3 values
primary
ok to contact
do not contact

Among all 6 fields i need to select only one field value is primary....


Any Help really Appreciate...

Thanks
varaprasad


 
I have a Parent Object called "Treatement" and a child object "Infusion". For a particular treatement we have to create infusion records. the 1st Infusion record should have infusion number (a field in Infusion) as 1 and 2nd record should have infusion number as 2 , and the count should continue. 

How to achive this..

Thanks 
Hi Everyone.

  i need small help regarding on schedule apex.
  how we will schedule one class with different timings.
EX:i want to schedule one class :  Runs at 4:20; 7:50: 16:20; 20:50 CET these timings.

Thanks in Advance


 
Hi All ,

   i am writing test class for following schedule class 
      global class scheduleAccountWriteXML implements Schedulable{
    
    // Execute method
    
    global void execute(SchedulableContext SC) {
        
        try{
      
// Code to be executed when the schedule class wakes up

            
            CalloutAccountRequest.basicAuthCalloutRequest();
           
            String CRON_EXP = '0 0 * * * ?';
            string jobName = 'Account_Interface_Schedule_job_that_runs_every_1_hour_for_Accounts'; 
            scheduleAccountWriteXML p = new scheduleAccountWriteXML();
            system.schedule(jobName, CRON_EXP, p);              
            
        }     
        
        Catch (Exception e){            
            
            Messaging.SingleEmailMessage emailMessage = new Messaging.SingleEmailMessage();
           
            emailMessage.setToAddresses(new String[] { 'varaprasad.vemula@accenture.com'});
            emailMessage.setSubject('Subject');
            
          
            emailMessage.setPlainTextBody(e.getmessage());
         
            Messaging.SendEmailResult[] emailResult = Messaging.sendEmail(new Messaging.SingleEmailMessage[] { emailMessage}, true);
        }
    }
}

I received code 90%,but test execution will be fail .

@isTest
public class Test_scheduleAccountWriteXML {
    public static testmethod void testaccountxml(){
    Test.StartTest();
              
            String CRON_EXP = '0 0 * * * ?';           
            scheduleAccountWriteXML scc6= new scheduleAccountWriteXML();       
            String jobid = system.schedule('varam', CRON_EXP, scc6);  
        
     Test.StopTest();  
        
         
    }
}


Any help please.


 
Hi Everyone ,

i created one class for generating xml file and by using callouts i am sending file to external system.
Here my requirement is 
  EX : file is more than one mb 1.5 mb
          i need to split xml file one is 1MB
                                          2nd one is 0.5mb
                                           is it possible to split file,,,,  Give me some ideas

Thanks all.
 
Hi

    I need to create multiple tasks in single page and i need to assign to user.Through vf page how we will implement this one .

 We need to have a VF section  so that from same page I can create multiple tasks without navigating to different page. Essentially in new task we need to have all the fields and can only refer what is in Action plan. 

Thanks to all ....
 

 
Hi All

   A and B are objects having lookup relationship
   A is parent and having status field
   B is child having status field
here my requiremeent is parent is having n on of childs in child what is the staus field value i need to update same thing in parent....

Thanks to alll
 
Hi I have come across the below error, using JavaScript in Button.

An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. 
If you believe you have additional information that may be of help in reproducing or correcting the error, please contact Salesforce Support.
 Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information.
 We apologize for the inconvenience. 

Thank you again for your patience and assistance. And thanks for using salesforce.com! 

Error ID: 1652772134-27944 (-1092651723)
 
{!REQUIRESCRIPT("/soap/ajax/15.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/15.0/apex.js")}
var r = "{!Opportunity.Opportunity_Product_Count__c}";
var oppid = "{!Opportunity.Id}";
 

if(r == 1 )
{        
                    window.location.href='/apex/VFPageName?id='+oppid;
}
else
{
    alert ("No Products exists !");

Please help me out with alternative solution ASAP
Hi All,

i need to create one validation rule..

User-added image

in each prefernce picklist field i have 3 values
primary
ok to contact
do not contact

Among all 6 fields i need to select only one field value is primary....


Any Help really Appreciate...

Thanks
varaprasad


 
I am calling the below class from the lighting component OR form devloper console and i am getting the same error in the debug log. Kindly help me to sort this. Response body is coming and when I am deserilizing the error is coming.  please help to sort this.

Debug log error message.
public class ApiCallLightningComponent {
 /*
 * @Name : - fetchUserSessionId
 * @Description: - Call the VF page and get the Log In Use Session Id
 * @Params : - none
 * @ReturnType : - String
 */
 public static String fetchUserSessionId(){
 String sessionId = '';
 // Refer to the Page
 PageReference reportPage = Page.GetSessionIdVF;
 // Get the content of the VF page
 String vfContent = reportPage.getContent().toString();
 System.debug('vfContent '+vfContent);
 // Find the position of Start_Of_Session_Id and End_Of_Session_Id
 Integer startP = vfContent.indexOf('Start_Of_Session_Id') + 'Start_Of_Session_Id'.length(),
 endP = vfContent.indexOf('End_Of_Session_Id');
 // Get the Session Id
 sessionId = vfContent.substring(startP, endP);
 System.debug('sessionId '+sessionId);
 // Return Session Id
 return sessionId;
 }
 /*
 * @Name - makeAPICall
 * @Description - Responsible for making API Call out
 * @params - None
 * @ReturnType - String
 */
 @AuraEnabled
 public static list<accountwrapper> makeAPICall(){
 String sessionId = fetchUserSessionId();
 HTTP h = new HTTP();
 HTTPRequest req = new HTTPRequest();
 HttpResponse resp = new HttpResponse();
 req.setMethod('GET');
 req.setHeader('Authorization', 'Bearer ' + sessionId);
     system.debug('coming here 1');
 req.setEndpoint(URL.getSalesforceBaseUrl().toExternalForm() + '/services/data/v41.0/query?q=Select+Id,+Name+From+Account');
 resp = h.send(req);
 System.debug('#### Response Status '+resp.getStatus());
 System.debug('#### Response Status Code '+resp.getStatusCOde());
 System.debug(resp.getBody());
    list<accountwrapper> accountwrapperList = new list<accountwrapper>();
    //  string temp = string.valueof(resp.getBody()).substringAfter('"records":');
      system.debug('the response:'+resp.getBody());
    // system.debug('the temp is:'+temp);
     accountwrapperList = (list<accountwrapper>)system.json.deserialize(resp.getBody(), list<accountwrapper>.class);
     // return JSON.serialize(resp.getBody());
     system.debug('The accountwrapperList is :'+accountwrapperList);
      return accountwrapperList;
 } 
    
    public class accountwrapper{
       @AuraEnabled public string Id;
       @AuraEnabled public string Name;
    }
}

 
Need to know complete trail (steps) to become a Salesforce developer
Hi,
public PageReference pageChange ()
    { 
        string vertical = ApexPages.currentPage().getParameters().get('vert');string PrinCode = ApexPages.currentPage().getParameters().get('PriCd');string ArnNo = ApexPages.currentPage().getParameters().get('Arn');
        string isrollover = ApexPages.currentPage().getParameters().get('Rollover');

I want to change String to boolean,but when I am giving it as Boolean isrollover = ......

It is showing error.Please help.
Trigger has limitation of the 100 SOQL records. It will exceed the SOQL query limit if more than 100 SOQL quries are made. 
In the second example of the documentation following line is mentioned:
If more than 20 records are pulled into this request, the trigger would exceed the SOQL query limit of 100 SELECT statements:
trigger MileageTrigger on Mileage__c (before insert, before update) {
   for(mileage__c m : Trigger.new){ 
      User c = [SELECT Id FROM user WHERE mileageid__c = m.Id];
   }
}

But it will count only 20 soql queries so it should not exceed the limitation.
 
Hi 

I am new in Salesforce Begineer

My Question is:

How to validate Phone field of Account Object with Use of Apex Class and the validation is ONly 10 Digit is input by user no sepcial character no characters Only digits and digit will be 10 
and if user input digit according the condition then the record will be save and user not input 10digit then error will be show on the Phone field "Please Provide Valid Number"  on Custom Visual force Page
Please help me ASAP


Thanks 
Neeraj Sharma
 
Hello. I am trying to use the invocableMethod annotation to pass some ids from a flow to the method that will return a list of custom Sobjects.

For some reason the soql is only finding the first record, and I don't see why. Posted here is the class and a debug log. Thanks for any help!!
 
public with sharing class getCampaigns_Flow {
    
    @invocableMethod
    public static list<list<Campaign__c>> getCampaigns(list<string> campaignIds) {
        system.debug('campaignIds: '+campaignIds);
        list<list<Campaign__c>> varCamps = new list<list<Campaign__c>>();
        List<string> varIds = campaignIds[0].split(';');
        system.debug('varIds: '+varIds);
        list<Campaign__c> camps = [select Id,
                                    Target_Audience__c,
                                    Geographic_Targeting__c,
                                    Search_Keywords__c,
                                    Creative_Versions_Per_Flight__c
                                    from Campaign__c
                                    where Id In :varIds];
        varCamps.add(camps);
        system.debug('camps: '+camps);
        system.debug('varCamps: '+varCamps);
        return varCamps;
    }
}
User-added image
 
There is an issue with my HTTP request.salesforce is not allowing me to use PATCH method.
Below are the notification which i get after calling a patch.

System.CalloutException: Invalid HTTP method: PATCH.

when we override the method with patch
req.setHeader('X-HTTP-Method-Override','PATCH');
req.setMethod('POST');
Then i am geeting below notification.
System.HttpResponse[Status=Method Not Allowed, StatusCode=405]
Can somebody help me here I am getting the error while getting data based on id which I am passing, I am able to generate session id as well.

Salesforce to Salesforce Rest Api Integration.

My code is,

public class restApiClassSalesforceorg1{


private string cKey='XXXXXX';
private string cSecret='XXXXXX';
private string uName='XXXXXX';
private string passwd='XXXXXX';

// Above information is hided


public class responseWrapper{

public string id;
public string access_token;
public string instance_url;

}

public string getRequestToken()
{
string reqBody='grant_type=password&client_id='+cKey+'&client_secret='+cSecret+'&username='+uName+'&password='+passwd;                                      

Http h=new Http();
HttpRequest req=new HttpRequest();
req.setBody(reqBody);
req.setMethod('POST');
req.setEndpoint('https://login.salesforce.com/services/oauth2/token');

HttpResponse hresp=h.send(req);
responseWrapper wResp=(responseWrapper)JSON.deserialize(hresp.getBody(),responseWrapper.class);
system.debug('Instance url'+wResp.instance_url);
system.debug('session id'+wResp.access_token);
return wResp.access_token;


}

public static list<Account> getConList()
{
list<account> accList1=new list<account>();
String accToken;
string ExternalId='SomeIDfromOtherOrg';
string responseBody;
string endPoint='https://ap5.salesforce.com/services/apexrest/v1/getAccountOnExternalId/' + ExternalId;
restApiClassSalesforceorg1 obj=new restApiClassSalesforceorg1();
accToken=obj.getRequestToken();
system.debug('access token'+ accToken);
if(accToken!='')
{
Http h1=new Http();
HttpRequest req1=new HttpRequest();
req1.setHeader('Authorization','Bearer'+accToken);
req1.setHeader('Content-Type','application/json');
//req1.setHeader('Accept','application/json');
req1.setMethod('GET');
req1.setEndpoint(endPoint);
HttpResponse hresp1=h1.send(req1);
responseBody=hresp1.getBody();
JSONParser parser=JSON.createParser(responseBody);
 while (parser.nextToken() != null) {
 Account obj1=new Account();
 if ((parser.getCurrentToken() == JSONToken.FIELD_NAME) && (parser.getText() == 'Name')) {
 
 string accName=parser.getText();
 obj1.name=accName;
 
 }
accList1.add(obj1);
}
}
return accList1;

}



}

Code from other org,

@RestResource(urlMapping='/v1/getAccountOnExternalId/*')
   global with sharing class getAccount {
     @Httpget
      global static list<Account> fetchAccount(){
        RestRequest req = RestContext.request;
        RestResponse res = Restcontext.response;
        string accId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
        list<Account> lstAcc=[Select id , name,ExternalIdForAccount__c from Account where Id=:accId ];
        
        return lstAcc;
      }
   }


 
Hello all,
Our Sales Cloud and Marketing Cloud are connected via the Marketing Cloud Connector.  I am trying to use the triggered send feature of Sales Cloud and send a Marketing Cloud email when a person account is created in the Sales Cloud.

I have the following trigger and test class set up on my Sandbox environment.
trigger Trig_Account on Account (after insert, after update) {
    if (!Test.isRunningTest()){
        et4ae5.triggerUtility.automate('Account');
    }
}

@isTest
private class Trig_AccountTest {
    static testMethod void myUnitTest() {
        Account testAccount = new Account(LastName = 'Test Account', PersonEmail= 'testclass@test.com');
        insert testAccount;
        testAccount = [select Id, LastName from Account where id = :testAccount.Id];
        System.assertEquals(testAccount.LastName, 'Test Account');
    }
}
The test class executes without any problems but the code coverage on the trigger remains at 50%(1/2).  I won't be able to deploy this to production because it needs to be at 75% at least.  I can't see what I am doing wrong here so any help will be apprecaited.
some one can help me how to test this method
My Controller Code:
... @RemoteAction
    public static List<JSStove> getStoves(Id ResellerID) {// include Id ResellerID from VF
        
        List<JSStove> stoves = new List<JSStove>();
        for (Product_item__c stove : [SELECT Id, Name FROM Product_item__c
                                      WHERE Reseller__c =:ResellerID ORDER BY Name ASC]) {                      
                                      
            stoves.add(new JSStove(stove.Name, stove.Id));
        }
        return stoves;
    }

Please help me.
Thanks in Advance
We're looking for a Salesforce developer to oversee the development and administration of our Salesforce instance.
Ideally, you're an independent Salesforce contractor who can contribute about 20h/week on a long term basis, enjoy working remotely and collaborate well with distributed team.
  • Salesforce Admin and Dev certified
  • Minimum 3 years of Salesforce application development
  • Experience with integration of systems and 3rd party apps within Salesforce
  • Experience with Marketo a plus
  • Knowledge of SFDC governor limits and guidelines
  • Experience working in an Agile or SCRUM environment
  • Ability to communicate technical recommendations to non-technical stakeholders 
  • Able to work remotely within PST business hours.
Hi,
We have person accounts enabled for our Salesforce instance.  I am using the Rest API to create an account record.  When an an account is created, there is formula field that gets calculated automatically to ge the long person contact id.  Is there a way to specifiy this attribute in the response?  I don't want to have to make a second call to get the long person contact id.
Hi, 

I am trying to execute Apex test (run synchronous) using rest explorer in workbench. But, the response is null. Please help me.

User-added image

Thanks and Regards,
Diwakar G
Hello,

When somone gives a swagger, What else do we need to do to do testing in Postman.

is there any authentcation key i should ask ?

I imported the swagger and i directly clicked on send
I get below error
{
    "code": "500",
    "name": "Internal Gateway Error",
    "message": "error unknown
}
 
public class SendAccountUsingRESTAPI {
  private final String clientId = 'XXXX';
   private final String clientSecret = 'XXXX';
   private final String username = 'XXXX';
   private final String password = 'XXXX';
  public class deserializeResponse
   {
      public String id;
      public String access_token;
   }
  public String ReturnAccessToken (SendAccountUsingRESTAPI acount)
   {
      String reqbody = 'grant_type=password&client_id='+clientId+'&client_secret='+clientSecret+'&username='+username+'&password='+password;
     Http h = new Http();
      HttpRequest req = new HttpRequest();
      req.setBody(reqbody);
      req.setMethod('POST');
      req.setEndpoint('https://ap4.salesforce.com/services/oauth2/token');
      HttpResponse res = h.send(req);
     deserializeResponse resp1 = (deserializeResponse)JSON.deserialize(res.getbody(),deserializeResponse.class);
     system.debug('@@@@access_token@@ = '+resp1 );
      return resp1.access_token;
   }
}

In this class I am trying to get the access token with the help of ReturnAccessToken() method. But due to some reason it is returning null. I am not getting the access token. All the details I get is Status code = 400 and Status = Bad request. Can anyboody please give a solution to this problem, because I've got stuck here for a long time.
I'm hoping someone can help.  We have a vendor that wrote this code for us (see below). I'm trying to run an Informatica task that updates some users records and this is the error I'm getting.  

Error loading into target [Contact] : Error received from salesforce.com.  Fields [].  Status code [CANNOT_MODIFY_MANAGED_OBJECT].  Message [addToCList: execution of AfterUpdatecaused by: System.QueryException: List has more than 1 row for assignment to SObject()].

I am updating 14 contact records but keep getting a failure and this message is what it's telling me.  But I don't understand what the problem is that is causing this message.  Hopefully someone can help me understand what is happening here.  I'm not a developer but I do understand what is written in the code, I just don't know why it's giving me this partiuclar error.  TIA for any assistance.  



Apex Code
trigger addToCList on Contact (after update) {
for (Contact cont : Trigger.New)
{

if (cont.Jenzabar_ID__c !=null)
{
if (cont.TargetX_SRMb__Student_Type__c=='First-Time Freshman'||cont.TargetX_SRMb__Student_Type__c=='International Freshman')
{
if (cont.TargetX_SRMb__Status__c=='Deposit Paid')
{
addAllAttachments.getAttachmentsForStudent(cont.X18_digit_ID__c,cont.Jenzabar_ID__c);
}
} else 
{
if (cont.TargetX_SRMb__Status__c=='Accept')
{
addAllAttachments.getAttachmentsForStudent(cont.X18_digit_ID__c,cont.Jenzabar_ID__c);

 
Hey guys,

I have a few active workflows that look at an opportunity, if there's been no activity for 21 days, it'll send a follow up email to the Contact who owns the opportunity. In order have the email sent I have to login as another user, make a minor change on the opportunity to trigger it (usually I'll have a checkbox and do a list view so it's quick), and then the email will send from him. The problem is that everyday because there's hundreds of opportunities I have to go in there and trigger all of these opportunities as him in order for the emails to be sent. Is it possible to create a workflow/process/flow (preferrably not apex) that will automatically check each opportunities "Trigger box" as him, so then the emails automatically send as him without me ever having to go in, login as him, and manually check each opportunities "Trigger box" in a list view???

Thanks!!!