• alkemacs
  • NEWBIE
  • 10 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 2
    Replies
I would like to know how can I enable the API client whitelisting feature.

Hi ! 

I got this error when I run a custome quick action which called an apex server side controller:

Something went wrong CloneInvitationLead.apxc:50: Insert failed. First exception on row 0; first error: INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST, bad value for restricted picklist field: INVITATION_WRONGCONTACT: [OPS_Invitation_reason__c]

It is weird because the API NAME of the picklist OPS_Invitation_reason__c mentionned is the right one...

I then relaxed at the picklist definition level the conditions:  "Restrict picklist to the values defined in the value set".

It worked but another weird things is that it did not create a new value in the picklist value set. It means that the value which was stared by the error and seems wrong is finally the right one...

Here is an snippet of my code concerned by this error:

            Id cleanId = (Id) oldId;
            
            // Load the old Lead with all fields
            String objectName = 'Lead';
            String query = 'SELECT';
            Map<String, Schema.SObjectField> objectFields = Schema.getGlobalDescribe().get(objectName).getDescribe().fields.getMap();
            // Grab the fields from the Lead and append them to the queryString one by one.
            for(String s : objectFields.keySet()) {
               query += ' ' + s + ', ';
            }
            query = query.subString(0,query.Length()-2);
            query += ' FROM ' + objectName;
            query += ' WHERE Id =  \''+ oldId +'\'  LIMIT 1';
            
            // Query the Lead object
            Lead ld = database.query(query);
            System.debug('Loaded <Lead ' + ld.Id + '>');
            
            // Create the new Lead and clone the previous one
            Lead newLd = ld.clone(false, false, false, false);

            // Update form fields
            newLd.FirstName = firstName;
            newLd.LastName = lastName;
            newLd.Email = email;
            newLd.Phone = phone;
            newLd.MobilePhone = mobilePhone;
            newLd.Title = title;
            
            // Update control fields
            newLd.Status = 'INVITATION_NEW';
            newLd.OPS_Primary_Lead__c = false;
            newLd.OPS_LeadCloned__c = ld.id;
    
            // Update qualification fields
            newLd.OPS_BouncedEmail__c = false;
            newLd.OPS_OpenedEmail__c = false;
            newLd.OPS_Not_Responding__c = false;
            newLd.OPS_SuppressedEmail__c = false;
            
            // Insert new Lead in Production
            insert newLd;

 

Can you help me please?

Hi ! 

I tried several time to create a custom onclickJavascript button in Salesforce with several codes but I got the same error all the time :

Unexpected token }

Here, you can find my code : 

{!REQUIRESCRIPT("/soap/ajax/40.0/connection.js")}

var urlcio = 'https://id:password@trck.customer.net/api/v1/customers/path';
var envelope = '{"name":"registration","data":{"price": "23.45", "product": "socks"}}';
 
sforce.connection.remoteFunction({
url : urlcio,
requestHeaders: {"Content-Type:application/json"},
requestData : envelope,
method : 'POST',
onSuccess : function(response) { alert('OK: '+response); },
onFailure : function(response) { alert('ERROR: '+response); },
});

Can you help me to solve this please ?

 

 

Hi ! 

I tried to create tasks with the REST API and update the "Name" field with a contact.

It worked well when I used "WhoId" : "00000WSSFSEFF",

but when I tried to use an external ID I got this error message : 

[{"message":"Cannot deserialize instance of reference from START_OBJECT value { or request may be missing a required field at [line:7, column:21]","errorCode":"JSON_PARSER_ERROR"}]
 

URL : https://domain.my.salesforce.com/services/data/v20.0/sobjects/task

BODY :
{ "OwnerId": "0000XXX0000",
"Type": "Email",
"Subject": "Upsell",
"Status": "Not Started",
"Priority":"Normale",
"WhoId": { "ExternalId__c" : 4051 }
}

I also tried "Who": { "ExternalId__c" : 4051 }, and lots of other syntax but nothing worked.

Can you help me to solve this, please ? 

Hi ! 

I tried several time to create a custom onclickJavascript button in Salesforce with several codes but I got the same error all the time :

Unexpected token }

Here, you can find my code : 

{!REQUIRESCRIPT("/soap/ajax/40.0/connection.js")}

var urlcio = 'https://id:password@trck.customer.net/api/v1/customers/path';
var envelope = '{"name":"registration","data":{"price": "23.45", "product": "socks"}}';
 
sforce.connection.remoteFunction({
url : urlcio,
requestHeaders: {"Content-Type:application/json"},
requestData : envelope,
method : 'POST',
onSuccess : function(response) { alert('OK: '+response); },
onFailure : function(response) { alert('ERROR: '+response); },
});

Can you help me to solve this please ?

 

 

Hi ! 

I tried to create tasks with the REST API and update the "Name" field with a contact.

It worked well when I used "WhoId" : "00000WSSFSEFF",

but when I tried to use an external ID I got this error message : 

[{"message":"Cannot deserialize instance of reference from START_OBJECT value { or request may be missing a required field at [line:7, column:21]","errorCode":"JSON_PARSER_ERROR"}]
 

URL : https://domain.my.salesforce.com/services/data/v20.0/sobjects/task

BODY :
{ "OwnerId": "0000XXX0000",
"Type": "Email",
"Subject": "Upsell",
"Status": "Not Started",
"Priority":"Normale",
"WhoId": { "ExternalId__c" : 4051 }
}

I also tried "Who": { "ExternalId__c" : 4051 }, and lots of other syntax but nothing worked.

Can you help me to solve this, please ?