Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 82002

Retrieve records depending upon a text field value

$
0
0

Hi Experts, we have a field on Account called new_newcode which holds a unique text in it and another entity B text field (new_transferfromcode) where it will be referenced manually. Initial architecture was messed up so they created Text fields instead of Lookups.

Here is the requirement, when new_transferfromcode is entered, it should pull address from Account based on the text entered in new_transferfromcode. Wrote this below code and it's not working, any help would be appreciated. Thank you. 

function codeDetails(executionContext) {
    debugger;
    formContext = executionContext.getFormContext();

    var Fromcode = formContext.getAttribute("new_transferfromcode").getValue();
var result; var req = new XMLHttpRequest(); req.open("GET", csjs.clientURLVersion() + "/api/data/v8.2/accounts?$select=new_newcode,new_physicaladdress,new_physicalcity,new_physicalstate,new_physicalzip,name,createdby&$filter=_new_newcode_value eq " + Fromcode + " &$orderby=createdby desc", true); req.setRequestHeader("OData-MaxVersion", "4.0"); req.setRequestHeader("OData-Version", "4.0"); req.setRequestHeader("Accept", "application/json"); req.setRequestHeader("Content-Type", "application/json; charset=utf-8"); req.setRequestHeader("Prefer", "odata.include-annotations=\"*\""); req.onreadystatechange = function () { if (this.readyState === 4) { req.onreadystatechange = null; if (this.status === 200) { var results = JSON.parse(this.response); var recordCount = results["@odata.count"]; for (var i = 0; i < results.value.length; i++) { var new_newcode = results.value[i]["new_newcode"]; var new_physicaladdress = results.value[i]["new_physicaladdress"]; var new_physicalcity = results.value[i]["new_physicalcity"]; var new_physicalstate = results.value[i]["new_physicalstate"]; var new_physicalstate_formatted = results.value[i]["new_physicalstate@OData.Community.Display.V1.FormattedValue"]; var new_physicalzip = results.value[i]["new_physicalzip"]; var name = results.value[i]["name"]; formContext.getAttribute("new_comments").setValue(new_physicaladdress); } } else { Xrm.Utility.alertDialog(this.statusText); } } }; req.send(); }



Viewing all articles
Browse latest Browse all 82002

Latest Images

Trending Articles



Latest Images