Salesforce Rest API create account
We are using the Salesforce Rest API to integrate our external website with Salesforce Sales Cloud. When a user registers on our website, we create a contact record in Salesforce. The response to the initial insert request includes the Contact ID. Is there a way we can have the initial request return more fields? On the SF side, we have a formula field that generates the 18 digits long contact ID and we need that returned to us for interacting with the Marketing Cloud. We can make another call to get this long contact ID but we are trying to avoid this extra call. Is what we are trying to do achievable?
apex rest-api api bulk-api website-integration
add a comment |
We are using the Salesforce Rest API to integrate our external website with Salesforce Sales Cloud. When a user registers on our website, we create a contact record in Salesforce. The response to the initial insert request includes the Contact ID. Is there a way we can have the initial request return more fields? On the SF side, we have a formula field that generates the 18 digits long contact ID and we need that returned to us for interacting with the Marketing Cloud. We can make another call to get this long contact ID but we are trying to avoid this extra call. Is what we are trying to do achievable?
apex rest-api api bulk-api website-integration
add a comment |
We are using the Salesforce Rest API to integrate our external website with Salesforce Sales Cloud. When a user registers on our website, we create a contact record in Salesforce. The response to the initial insert request includes the Contact ID. Is there a way we can have the initial request return more fields? On the SF side, we have a formula field that generates the 18 digits long contact ID and we need that returned to us for interacting with the Marketing Cloud. We can make another call to get this long contact ID but we are trying to avoid this extra call. Is what we are trying to do achievable?
apex rest-api api bulk-api website-integration
We are using the Salesforce Rest API to integrate our external website with Salesforce Sales Cloud. When a user registers on our website, we create a contact record in Salesforce. The response to the initial insert request includes the Contact ID. Is there a way we can have the initial request return more fields? On the SF side, we have a formula field that generates the 18 digits long contact ID and we need that returned to us for interacting with the Marketing Cloud. We can make another call to get this long contact ID but we are trying to avoid this extra call. Is what we are trying to do achievable?
apex rest-api api bulk-api website-integration
apex rest-api api bulk-api website-integration
edited 3 hours ago
Oleksandr Berehovskiy
9,76532038
9,76532038
asked 4 hours ago
degmodegmo
304
304
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
yes, it is possible by means of creating custom rest resource in salesforce and inserting contact via this endpoint.
you want to add one more additional step before returning newly created contact. This step is to query this 18 digits long contact ID field. for example:
@RestResource(urlMapping='/ContactInsertWithReturnedFields/*')
global with sharing class MyRestResource {
@HttpPost
global static String doPost(String lastName) {
Contact cont = new Contact(
LastName = lastName
);
insert cont;
cont = [
select Id, LongContactId__c // query all needed fields to be returned on insert call
from Contact
where Id = :cont.Id
limit 1
];
return cont;
}
}
in this case endpoint is https://instance.salesforce.com/services/apexrest/ContactInsertWithReturnedFields/
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "459"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f247648%2fsalesforce-rest-api-create-account%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
yes, it is possible by means of creating custom rest resource in salesforce and inserting contact via this endpoint.
you want to add one more additional step before returning newly created contact. This step is to query this 18 digits long contact ID field. for example:
@RestResource(urlMapping='/ContactInsertWithReturnedFields/*')
global with sharing class MyRestResource {
@HttpPost
global static String doPost(String lastName) {
Contact cont = new Contact(
LastName = lastName
);
insert cont;
cont = [
select Id, LongContactId__c // query all needed fields to be returned on insert call
from Contact
where Id = :cont.Id
limit 1
];
return cont;
}
}
in this case endpoint is https://instance.salesforce.com/services/apexrest/ContactInsertWithReturnedFields/
add a comment |
yes, it is possible by means of creating custom rest resource in salesforce and inserting contact via this endpoint.
you want to add one more additional step before returning newly created contact. This step is to query this 18 digits long contact ID field. for example:
@RestResource(urlMapping='/ContactInsertWithReturnedFields/*')
global with sharing class MyRestResource {
@HttpPost
global static String doPost(String lastName) {
Contact cont = new Contact(
LastName = lastName
);
insert cont;
cont = [
select Id, LongContactId__c // query all needed fields to be returned on insert call
from Contact
where Id = :cont.Id
limit 1
];
return cont;
}
}
in this case endpoint is https://instance.salesforce.com/services/apexrest/ContactInsertWithReturnedFields/
add a comment |
yes, it is possible by means of creating custom rest resource in salesforce and inserting contact via this endpoint.
you want to add one more additional step before returning newly created contact. This step is to query this 18 digits long contact ID field. for example:
@RestResource(urlMapping='/ContactInsertWithReturnedFields/*')
global with sharing class MyRestResource {
@HttpPost
global static String doPost(String lastName) {
Contact cont = new Contact(
LastName = lastName
);
insert cont;
cont = [
select Id, LongContactId__c // query all needed fields to be returned on insert call
from Contact
where Id = :cont.Id
limit 1
];
return cont;
}
}
in this case endpoint is https://instance.salesforce.com/services/apexrest/ContactInsertWithReturnedFields/
yes, it is possible by means of creating custom rest resource in salesforce and inserting contact via this endpoint.
you want to add one more additional step before returning newly created contact. This step is to query this 18 digits long contact ID field. for example:
@RestResource(urlMapping='/ContactInsertWithReturnedFields/*')
global with sharing class MyRestResource {
@HttpPost
global static String doPost(String lastName) {
Contact cont = new Contact(
LastName = lastName
);
insert cont;
cont = [
select Id, LongContactId__c // query all needed fields to be returned on insert call
from Contact
where Id = :cont.Id
limit 1
];
return cont;
}
}
in this case endpoint is https://instance.salesforce.com/services/apexrest/ContactInsertWithReturnedFields/
edited 3 hours ago
answered 3 hours ago
Oleksandr BerehovskiyOleksandr Berehovskiy
9,76532038
9,76532038
add a comment |
add a comment |
Thanks for contributing an answer to Salesforce Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f247648%2fsalesforce-rest-api-create-account%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown