Hello Experts,
I have used the Below code for passing parameters to the custom action , am getting Unexpected token u in JSON at position 0,please suggest me regarding this
Hello Experts,
I have used the Below code for passing parameters to the custom action , am getting Unexpected token u in JSON at position 0,please suggest me regarding this
Hi Amruta,
First thing, you are trying with unsupported way to get field values in html web resource.
I will suggest you to use form context to get field values, please refer below url for reference:
Also try with parent before Xrm library as below:
parent.Xrm.WebApi.online.execute
Hi Amrutha,
Please refer to following links:
https://community.dynamics.com/crm/b/jasonlattimersblog/posts/use-xrm-webapi-in-a-stand-alone-web-resource
https://stackoverflow.com/questions/51416490/using-xrm-webapi-method-in-web-resource-opened-in-a-new-window/
In addition to answers from Jason Lattimer and the StackOverflow question:
From my test, I removed ClientGlobalContext.js.aspx and following part of code:
It works for me.
You could remove them if unnecessary.
Regards,
Clofly
Hi Clofly,
I tried the above operation what u mentioned still same error "SyntaxError: Unexpected token u in JSON at position 0↵ at JSON.parse (<anonymous>)↵ at Function.XrmClientApi.WebApi.Serialization.ODataSerializer.getPrimaryKey"
Hi Amrutha,
I would suggest you check the following points:
1. Whether name of the action you are calling is correct, it should be the "Unique Name" value of the action.
2. Whether name of input parameters are correct.
3. Whether ID extracted from URL is correct.
var id = queryStrings[0][1];
(It is should be something like 0215534a-0d42-40e9-8a0a-c973bb6bfc8f.)
Try troubleshooting by following operations:
1. Call the action directly with static value to test whether it would execute successfully.
2. Replace Xrm.Utility.alertDialog(error.message) with console.log(error), the error object may contains more error details.
3. Clear browser cache.
In addition, I think the reason would be that you were running web resource, the location of web resource is child of form.
You could change window.location.search to parent.window.location.search to check whether the URL parameters could be searched.
(And due to the reason, replace Xrm.WebApi with parent.Xrm.WebApi if necessary.)
Regards,
Clofly
Daivat Vartak (v-9d...
220
Super User 2025 Season 1
Vahid Ghafarpour
78
Super User 2025 Season 1
Sahra
43