1

I want to create lead in dynamic crm from my website. My website is build using HTML as this is a static site. I need to call dynamic crm (setup on premises) api from contact us page to submit data in dynamic crm.

Please suggest me a right direction.

Thanks

2 Answers 2

1

The SDK has lots of helpful information, have you looked at it? Here's a start:

Authenticating to CRM from JS using adal.js

Perform operations using the Web API

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your reply Polshgiant. but adal.js required an azure account first. can we have any option without this?
1

This is a sample code we use to submit entries from webpage to CRM. Hope this helps:

function CreateWebLeadInCRM(SourceCampaignName, Email, MobilePhone, FirstName, LastName, CompanyName){
var webLead = new Object();

//Add Source Campaing name
if(SourceCampaignName != null)
    webLead.sof_sourcecampaign = SourceCampaignName;
//Add Email
if(Email != null)
    webLead.sof_Email = Email;
//Add Mobile phone
if(MobilePhone != null)
    webLead.sof_MobilePhone = MobilePhone;
//Add First name
if(FirstName != null)
    webLead.sof_FirstName = FirstName;
//Add Last name
if(LastName != null)
    webLead.sof_LastName = LastName;
//Add Company name
if(CompanyName != null)
    webLead.sof_CompanyName = CompanyName;


var jsonwebLead = JSON.stringify(webLead);
var createwebLeadReq = new XMLHttpRequest();    
createwebLeadReq.open("POST", "http://SERVER/ORG/XRMServices/2011/OrganizationData.svc/sof_webleadSet", true, "USERNAME", "PASSWORD");
createwebLeadReq.setRequestHeader("Accept", "application/json");
createwebLeadReq.setRequestHeader("Content-Type", "application/json; charset=utf-8");
createwebLeadReq.onreadystatechange = function () {
    createwebLeadReqCallBack(this);
};
createwebLeadReq.send(jsonwebLead);

Ugly thing about this approach is that you have to save your password inside your javascript function, which is not really safe approach.. On the other hand you should only allow this user to insert entries to only one custom table without possibility to do anything else inside your CRM. This way you could manage what happens if you get spammed by the bots.

1 Comment

Thanks Andrius. Yes there is a big security risk. Anyone can see my credentials in web page. Is there any other approach except Azure Authentication?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.