SBX - Search With Button

SBX - Forum Post Title

need to get data from html webresource

Microsoft Dynamics CRM Forum

Hemanth Reddy.B asked a question on 15 May 2019 10:59 PM

Question Status

Suggested Answer

Hello friends,

On button click on crm contact page i will open html page replicate to contact (same fields but all text fields). after entering data on html page and click on submit i need to retrieve all fields data and place it in crm contact fields.. how can i do this using java script.. a little bit help please.

thanks

Reply
N.A.R.A responded on 15 May 2019 11:38 PM

Hi you can Xrm.Internal.openDialog to call HTML form

and using CallbackFucntion to get the data return from HTML

u must add ClientGlobalContext.js.aspx to the HTML so you can return the value form HTML

You can see this tutorial

https://nishantrana.me/2015/06/17/using-xrm-internal-opendialog-as-an-alternate-to-showmodaldialog-in-crm/

Reply
Preeti Sharma responded on 15 May 2019 11:49 PM
My Badges
Suggested Answer

Hi,

After entering data on the custom HTML form on click of Submit you need to get just fields of current form.

Once you get attributes you can update fields on Contact form.

To get attributes you can write below script:

window.opener.Xrm.Page.getAttribute('fieldname').getValue();

Hope this helps:)

Thanks

Preeti Sharma.

Reply
Dynamics365 Rocker responded on 16 May 2019 2:11 AM
My Badges
Suggested Answer

You have to retrieve certain field of contact.

You can use fetch xml or can use below script:

var formContext=ExecutionContext.getFormContext;

window.opener.formContext.getAttribute('fieldname').getValue();

Reply
Pravin Pawar responded on 16 May 2019 3:47 AM
My Badges
Suggested Answer

Hi Hemanth Reddy,

As you have mentioned here that you are using text fields inside HTML to replicate data from contact. Are you trying it for all data types I mean lookup, optionset, boolean, etc.

If are just placing single line text or multiline text then you need to use

window.opener.Xrm.Page.getAttribute('fieldlogicalname').setValue(ValueHere);

Reply
Inogic responded on 16 May 2019 6:11 AM
My Badges

Hi Hemanth,

In order to work with HTML Web resource you must need to add reference to ClientGlobalContext.js.aspx in your HTML Code as shown below:

 

<script src="../ClientGlobalContext.js.aspx"></script>

 

Also add reference to JavaScript Web Resource which you will call on click of Submit button.

 

After clicking submit button, function will retrieve data of all text fields in HTML using JavaScript or Query as shown below:

 

Using JavaScript:

var text=document.getElementById("txtvalue").value

 

Using Query:

var text=$("# txtvalue ").val()

Once you have the data of text fields in HTML, you can easily map field value to the fields in CRM as shown below:

window.opener.Xrm.Page.getAttribute("fieldvalue").setValue(text);

Thanks!

Reply
Preeti Sharma responded on 15 May 2019 11:49 PM
My Badges
Suggested Answer

Hi,

After entering data on the custom HTML form on click of Submit you need to get just fields of current form.

Once you get attributes you can update fields on Contact form.

To get attributes you can write below script:

window.opener.Xrm.Page.getAttribute('fieldname').getValue();

Hope this helps:)

Thanks

Preeti Sharma.

Reply
Dynamics365 Rocker responded on 16 May 2019 2:11 AM
My Badges
Suggested Answer

You have to retrieve certain field of contact.

You can use fetch xml or can use below script:

var formContext=ExecutionContext.getFormContext;

window.opener.formContext.getAttribute('fieldname').getValue();

Reply
Pravin Pawar responded on 16 May 2019 3:47 AM
My Badges
Suggested Answer

Hi Hemanth Reddy,

As you have mentioned here that you are using text fields inside HTML to replicate data from contact. Are you trying it for all data types I mean lookup, optionset, boolean, etc.

If are just placing single line text or multiline text then you need to use

window.opener.Xrm.Page.getAttribute('fieldlogicalname').setValue(ValueHere);

Reply

SBX - Two Col Forum

SBX - Migrated JS