Hi All,
I Have a look up field in Account form which name is new_country and the same field on Qucik create form of Contact. I want pass thes record from Main form of Contact to contact Quick create Form:
I have used this below code and add it to quick Create form in Contact (On Load):
function SetLocalStorage(executionContext){
var formContext = executionContext.getFormContext();
var country = formContext.getControl("New_country").getAttribute().getValue().toString();
localStorage.setItem("Country",country);
}
and this below code on field of Country (onChange) in Account main form:
function RetrieveStorageValue(executionContext){
var formContext = executionContext.getFormContext();
var country = localStorage.getItem("Country");
formContext.getAttribute("New_address1country").setValue(country);
localStorage.removeItem("Country");
}
I recieved an Error: Cannot read property 'setValue' of null
Does anybody have any idea?
Thank you in advance
Regrads
Hello Elpibato,
I also found the similar request within this forum and as Andrew also mentioned, you can try to use mappings.
Please see following URL:
- community.dynamics.com/.../291929
Further, as an alternative, you can also try to use the operation completely by code, using similar to the previous known function "openQuickCreate". Please note, this function is already marked as deprecated and replaced by Xrm.Navigation.openForm:
- docs.microsoft.com/.../jj602956(v=crm.8)
- docs.microsoft.com/.../xrm-utility
- docs.microsoft.com/.../openform
Best regards
Hi Elpibato,
Please use JSON.Stringify to save the value in local storage and then use JSON.Parse to reconstruct the object after retrieving from the local storage.
Here is a blog that explains the same carldesouza.com/.../
Also you must ensure that an array is passed as value to setValue of lookup field, the first element in the array is expected to be the object that represents the selected value.
So whatever you do with storage , finally this structural requirement should be met while assigning values to lookup field
community.dynamics.com/.../how-to-get-and-set-a-lookup-field-using-javascript-in-dynamics-365
Also Andrew pointed out take care of case sensitivity of field names. Let me know if you have any further questions otherwise please mark it as an answer.
Regards,
Praveen T
D365 Customization Support
Microsoft Corportation
Hello,
The main reason why your code doesn't work is because you should use all field names in lowercase - new_country, not New_country and new_address1country, not New_address1country.
Anyway there is no need to write any code because you can use mapping to pass that field - www.marksgroup.net/.../
Hi Elpibato,
Please use JSON.Stringify to save the value in local storage and then use JSON.Parse to reconstruct the object after retrieving from the local storage.
Here is a blog that explains the same carldesouza.com/.../
Also you must ensure that an array is passed as value to setValue of lookup field, the first element in the array is expected to be the object that represents the selected value.
So whatever you do with storage , finally this structural requirement should be met while assigning values to lookup field
community.dynamics.com/.../how-to-get-and-set-a-lookup-field-using-javascript-in-dynamics-365
Also Andrew pointed out take care of case sensitivity of field names.
Regards,
Praveen T
D365 Customization Support
Microsoft Corportation
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156