• Hemanth Bakthavatsalu
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 8
    Replies
We have written a apex code to delete the followers on Opportunities for which close date is older than 30 days.

Now I am trying to recover some of deleted records from EntitySubscription object, however I cannot find these records in EntitySubscription object. (I used workbench and selected the option to include deleted records, but still there are no results and also I used ALL ROWS option, still did not work)

I tested in sandbox by following an opportunity and unfollowed that Opportunity and then I cannot find that record in EntitySubscription object deleted records list.

1. Does EntitySubscription object does not support recovery of records from recycle bin
2. Is there any way to retrieve EntitySubscription deleted records.
From Salesforce I am trying  to make restful api call to a CPQ system.

1. I am able to make a login (POST request)
2. I am able to query the Account object & retrieve the id & fields on the Account object in the external system through (GET request)
3. Now I need to update the Account record with a value from Salesforce

Example: I have written the JSON Generator code to update Account name on the external system using the Id of the Account retrieved.


        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
        
        JSONGenerator gen = JSON.createGenerator(true);
        gen.writeStartArray();
        gen.writeStartObject();
        gen.writeStringField('Id', '0ca0000f8pxds72r');
        gen.writeStringField('Name', 'TEST12345');
        gen.writeEndObject();
        gen.writeEndArray();
        String jsonOrders1 = gen.getAsString();
        System.debug('jsonOrders: ' + jsonOrders1 );

        req.setMethod('POST');        
        req.setEndpoint('https://cpq.com/rs/8/cpq'); 
        req.setHeader('Content-Type', 'application/json');
        req.setBody(jsonOrders1);                     
        req.setCompressed(true);
        res = http.send(req);
        
        Status code = 400;
        Message: content was not a valid JSON object
        
        I tested the same Post request using the Postman plugin in Chrome and it successfully updated the Account on the external system.
        Below is the JSON Body which I used in the Postman; when I print my json request in Salesforce, I am getting the similar JSON response.
        Can anyone help in trouble shooting this issue. What am I doing wrong in creating the JSON request.
        
        JSON used in Postman:
        [
             {"Id":"0ca0000f8pxds72r","Name":"TEST123"}
        ]  
        
        JSON when I print in debug logs in Salesforce:
         [ { "Id" : "0ca0000f8pxds72r",  "Name" : "TEST12345"} ]
        
        I was referring their api documentation. Look under the CPQ OnDemand Web Services API Calls (RESTful) header (Create/Update object)
        http://docs.fpx.com/docs/api/restful/14/
We are using standard case and solutions object which is used by the full license users.

However we have a custom case and  custom solution object, which is synchronized between the standard case and solution object using trigger on the standard case and solution..( custom case & solution object functionality was built for field tech's as we cannot afford the full license for every tech)

Challenge is synchronizing the standard case-solution junction object with custom case-solution junction object, as we cannot write a trigger on the junction object..(Is salesforce planning to introduce this functionality any time soon)

So we are planning to override the solution search page with vf page, in order to capture the select and delete of a solution on a case, should we override the "select" and " delete" links on the solution object..

Any other suggestions or solutions for this scenario...
I am trying make a API call to an external system (CPQ) from the Salesforce.
1. I am able to successfully login to the external system through http post
2. After successful login, now I want to query Account object on the external system and retrieve the results
3. How do i make a query to the external system using Get method. When I make a external call after login, using a new request object with GET method, I am getting Unauthorized error.

Error that I am getting: System.HttpResponse[Status=Unauthorized, StatusCode=401]
The external system is CPQ (fpx vendor). Below is the API document that was shared

http://docs.fpx.com/docs/api/restful/14/html/cpq_login_(post).html



Below is the code:

public void cpqCallOut() {

        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
        String strname = 'Username';
        String strpwd= 'password';
        
         Blob headerValue = Blob.valueOf(strname+':'+strpwd);
                String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);
        
        
        
        String SessionId = Userinfo.getSessionId();
        String strURL = System.URL.getSalesforceBaseURL().toExternalForm();
        
        req.setHeader('Authorization', authorizationHeader);
        req.setEndpoint('https://sbx.fpx.com/rs/8/cpq/login');
        req.setMethod('POST');
        req.setBody('un ='+EncodingUtil.urlEncode(strname, 'UTF-8') + 'pw =' + EncodingUtil.urlEncode(strpwd, 'UTF-8') +
        'SfdcSessionID  =' + EncodingUtil.urlEncode(SessionId, 'UTF-8') + 
        'SfdcServerURL ='+  EncodingUtil.urlEncode(strURL , 'UTF-8'));
        req.setCompressed(true); // otherwise we hit a limit of 32000
        
        String strQuery = 'Select+name+from+Account+where+id+=+158000000000010'; 
        
        //new request object
        HttpRequest req1 = new HttpRequest();
        HttpResponse res1 = new HttpResponse();
        Http http1 = new Http();
     
        try {
            res = http.send(req);
        
         if(res.getStatusCode()== 200)
            {
                System.debug('SUCCESS!!!');
                
               req1.setMethod('GET');               
               req1.setEndpoint('https://sbx.fpx.com/rs/8/cpq?query='+ strQuery);
               req1.setCompressed(true);
               res = http.send(req1);
                
               System.debug('MY REQUEST===>'+req1.toString());
               System.debug('RESPONSE FROM CPQ 2222'+res.toString());
            }
        
        } catch(System.CalloutException e) {
            System.debug('Callout error: '+ e);
            System.debug('RESPONSE FROM CPQ'+res.toString());
        }
    }
}
I have created a custom list button on Opportunity, which takes the user's country and other details from user record and auto populates on Opportunity creation.

If I use the same custom button on Opportunity related list on Accounts, the Account is not getting auto populated on the opportunity; whereas the standard "New Opportunity" button on Opportunity related list on Account record, auto populates the Account name on Opportunity.

How do I make the custom Opportunity creation button to auto populate the Account name on Opportunity creation (when we create the opportunity from Account)
We have are planning to keep the accounts in Salesforce and CPQ system in sync.

I am trying to make a CPQ OnDemand Web Services API Call (RESTful) from a trigger to create/update a Account on the CPQ system, whenever a Account is created or updated in Salesforce..

Below is the code that i have written so far:

public class WebServiceCallout {

public static void cpqCallOut() {
HttpRequest req = new HttpRequest();
HttpResponse res = new HttpResponse();
Http http = new Http(); String strname = 'MYsfdcUsername@abc.com';
//String strsession = getsessionid();
req.setEndpoint('https://sbx.fpx.com/rs/8/cpq/login');
req.setMethod('POST');
req.setBody('username ='+EncodingUtil.urlEncode(strname, 'UTF-8') );
req.setCompressed(true);
try {
res = http.send(req);
} catch(System.CalloutException e)
{ System.debug('Callout error: '+ e);
System.debug(res.toString()); } }}

Can anyone please guide me on how to retrieve the API sfdc Sessionid and sfdc server url from the apex code and make the updates in the external system (CPQ)

Below are the steps that I am trying to follow..I am new to writing REST API webservice callouts from Salesforce..

CPQ API: http://docs.fpx.com/docs/api/restful/14/. Look under the CPQ OnDemand Web Services API Calls (RESTful) header

Going to need three calls in particular:
1. Login - The first step will be to log in to CPQ. You will want to use the sfdcsessionid and sfdcserverurl parameters
2. Query - When updating existing Accounts you will need their CPQ ID. You can query all of the existing accounts with something like SELECT Id, ExternalId FROM Account and then match the Id (CPQ ID) to ExternalID (SFDC ID)
3. Create/Update Object - The JSON object passed in the body of this call can contain multiple accounts to create/update at once. For new accounts be sure to specify the "type":"Account" field. For accounts being updated, you can pass only the fields that need to be modified.
I have created a custom button using Javascript on Opportunity. On the opportunity object we already have relationship field which relates back to Opportunity (like Parent-Child).

The javascript button will copy the values of certain field from the Parent opportunity and auto populate in the new child opportunity created. All the values are copied to child opportunity, but except for picklist values which has "&" in the value.. When i use urlencode like below, it is throwing the below error:

00NK0000001jyxH={!URLENCODE(Opportunity.ABC__c)}

Error: Field Opportunity.HBS_ePSF_Branch_Location__c is a picklist field. Picklist fields are only supported in certain functions.
 
From Salesforce I am trying  to make restful api call to a CPQ system.

1. I am able to make a login (POST request)
2. I am able to query the Account object & retrieve the id & fields on the Account object in the external system through (GET request)
3. Now I need to update the Account record with a value from Salesforce

Example: I have written the JSON Generator code to update Account name on the external system using the Id of the Account retrieved.


        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
        
        JSONGenerator gen = JSON.createGenerator(true);
        gen.writeStartArray();
        gen.writeStartObject();
        gen.writeStringField('Id', '0ca0000f8pxds72r');
        gen.writeStringField('Name', 'TEST12345');
        gen.writeEndObject();
        gen.writeEndArray();
        String jsonOrders1 = gen.getAsString();
        System.debug('jsonOrders: ' + jsonOrders1 );

        req.setMethod('POST');        
        req.setEndpoint('https://cpq.com/rs/8/cpq'); 
        req.setHeader('Content-Type', 'application/json');
        req.setBody(jsonOrders1);                     
        req.setCompressed(true);
        res = http.send(req);
        
        Status code = 400;
        Message: content was not a valid JSON object
        
        I tested the same Post request using the Postman plugin in Chrome and it successfully updated the Account on the external system.
        Below is the JSON Body which I used in the Postman; when I print my json request in Salesforce, I am getting the similar JSON response.
        Can anyone help in trouble shooting this issue. What am I doing wrong in creating the JSON request.
        
        JSON used in Postman:
        [
             {"Id":"0ca0000f8pxds72r","Name":"TEST123"}
        ]  
        
        JSON when I print in debug logs in Salesforce:
         [ { "Id" : "0ca0000f8pxds72r",  "Name" : "TEST12345"} ]
        
        I was referring their api documentation. Look under the CPQ OnDemand Web Services API Calls (RESTful) header (Create/Update object)
        http://docs.fpx.com/docs/api/restful/14/
I am trying make a API call to an external system (CPQ) from the Salesforce.
1. I am able to successfully login to the external system through http post
2. After successful login, now I want to query Account object on the external system and retrieve the results
3. How do i make a query to the external system using Get method. When I make a external call after login, using a new request object with GET method, I am getting Unauthorized error.

Error that I am getting: System.HttpResponse[Status=Unauthorized, StatusCode=401]
The external system is CPQ (fpx vendor). Below is the API document that was shared

http://docs.fpx.com/docs/api/restful/14/html/cpq_login_(post).html



Below is the code:

public void cpqCallOut() {

        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
        String strname = 'Username';
        String strpwd= 'password';
        
         Blob headerValue = Blob.valueOf(strname+':'+strpwd);
                String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);
        
        
        
        String SessionId = Userinfo.getSessionId();
        String strURL = System.URL.getSalesforceBaseURL().toExternalForm();
        
        req.setHeader('Authorization', authorizationHeader);
        req.setEndpoint('https://sbx.fpx.com/rs/8/cpq/login');
        req.setMethod('POST');
        req.setBody('un ='+EncodingUtil.urlEncode(strname, 'UTF-8') + 'pw =' + EncodingUtil.urlEncode(strpwd, 'UTF-8') +
        'SfdcSessionID  =' + EncodingUtil.urlEncode(SessionId, 'UTF-8') + 
        'SfdcServerURL ='+  EncodingUtil.urlEncode(strURL , 'UTF-8'));
        req.setCompressed(true); // otherwise we hit a limit of 32000
        
        String strQuery = 'Select+name+from+Account+where+id+=+158000000000010'; 
        
        //new request object
        HttpRequest req1 = new HttpRequest();
        HttpResponse res1 = new HttpResponse();
        Http http1 = new Http();
     
        try {
            res = http.send(req);
        
         if(res.getStatusCode()== 200)
            {
                System.debug('SUCCESS!!!');
                
               req1.setMethod('GET');               
               req1.setEndpoint('https://sbx.fpx.com/rs/8/cpq?query='+ strQuery);
               req1.setCompressed(true);
               res = http.send(req1);
                
               System.debug('MY REQUEST===>'+req1.toString());
               System.debug('RESPONSE FROM CPQ 2222'+res.toString());
            }
        
        } catch(System.CalloutException e) {
            System.debug('Callout error: '+ e);
            System.debug('RESPONSE FROM CPQ'+res.toString());
        }
    }
}
I have created a custom button using Javascript on Opportunity. On the opportunity object we already have relationship field which relates back to Opportunity (like Parent-Child).

The javascript button will copy the values of certain field from the Parent opportunity and auto populate in the new child opportunity created. All the values are copied to child opportunity, but except for picklist values which has "&" in the value.. When i use urlencode like below, it is throwing the below error:

00NK0000001jyxH={!URLENCODE(Opportunity.ABC__c)}

Error: Field Opportunity.HBS_ePSF_Branch_Location__c is a picklist field. Picklist fields are only supported in certain functions.
 

Hi All,

 

I am trying to create a trigger on the CaseSolution object in SF. I am using the Force.com IDE plugin for eclipse. When I go to create a new trigger, CaseSolution is not in the list of available objects. I ran updates for the IDE to make sure there were no updates from SF and there were none. Is there a reason that I can't create a trigger on this object? Has anyone else ran into this before?