cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
noorahmad001
Frequent Visitor

Portal Web API create contact and set account of newly created contact

 

Hi Folks 

 

I am trying to create contact via Portal Web API + LIQUID code. I tried the below code to set the Account/Company of the newly created contact but I am getting 403.

 

// {% assign parentcustomerid = user.parentcustomerid.Id %}

 

var fname = $('#fname').val();
var lname = $('#lname').val();
var email = $('#email').val();
//var parentcustomerid = '{{parentcustomerid}}'
var dataObject = {
"emailaddress1": email,
"firstname": fname,
"lastname": lname,
"parentcustomerid_account":'{{parentcustomerid}}'

};
//"parentcustomerid_account":parentcustomerid
//"parentcustomerid":parentcustomerid

 
webapi.safeAjax({
type: "POST",
url: "/_api/contacts",
contentType: "application/json",
data: JSON.stringify(dataObject),
success: function (res, status, xhr) {
//print id of newly created entity record
console.log("entityID: " + xhr.getResponseHeader("entityid"))
}
});

 

I tried the  

 

noorahmad001_0-1619045165370.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
Fubar
Solution Sage
Solution Sage

The association is usually a data bind

"xxx_Customer_contact@odata.bind": "/contacts({{ user.id }})"

The case of the letters in the fieldname may not all be lowercase (e.g. above when i defined Customer it had a caps 'C')

Depending on the detail of the error the request-response in the browser usually has a bit more detail.

Another trick to workout if its a fieldname issue is to try with and asterisk * for the field list in your Site Settings rather than listing out all the fields.

View solution in original post

2 REPLIES 2
Fubar
Solution Sage
Solution Sage

The association is usually a data bind

"xxx_Customer_contact@odata.bind": "/contacts({{ user.id }})"

The case of the letters in the fieldname may not all be lowercase (e.g. above when i defined Customer it had a caps 'C')

Depending on the detail of the error the request-response in the browser usually has a bit more detail.

Another trick to workout if its a fieldname issue is to try with and asterisk * for the field list in your Site Settings rather than listing out all the fields.

View solution in original post

@Fubar thank you.

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Users online (88,329)