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

Setting LookupValue doesn't fill the with oDataQuery

$
0
0

Hi CRM Brilliant People :)

I'm facing an issue with a Js source, i need to add a value to a lookup field by retrieving a value from another entity by his name, not by his guid, why? because i only have a text value to do the retrieve, so my issue is when i'm trying to set the value on the lookup after create the array object it always shows the array objects as undefined, so, here's the code

function setFY(Year){
	
	var dateFieldValue = Xrm.Page.getAttribute("new_startdate").getValue();
	var Year = dateFieldValue.getFullYear().toString();
	var FY_Field = Xrm.Page.getAttribute("new_estimatedfiscalyear").getValue();
	
	var FY_Data = My.oData.GetEntityRecords("new_fiscalyear", null, "new_name,new_fiscalyearId,new_code", "new_name eq '" + Year + "'", false, null, null, null);
	
	var FiscalYear = new Array();
	FiscalYear[0] = new Object();
	FiscalYear[0].id = "{"+FY_Data[0].new_name.Id+"}";
	FiscalYear[0].name = FY_Data[0].new_name.Name;
	FiscalYear[0].entityType = FY_Data[0]new_name.LogicalName;
	
	if(FY_Data != null && FY_Data != undefined){
		
		Xrm.Page.getAttribute("new_estimatedfiscalyear").setValue(FiscalYear[0].name);
		Xrm.Page.getAttribute("new_estimatedfiscalyear").setSubmitMode("always");
		
	}	else if (FY_Field == Year)	{
		
		return false;
		
	}
}

I'm debuggin the JS and it retrieves correctly, but the fail is with the array, always alert undefined, each attribute (ID, Name, LogicalName) but on the alert from the OData Query  get the value that i need, and for that the lookup field doesn't get filled...

Any clue that anyne can give's me on this?

Thank you, best regards!


Viewing all articles
Browse latest Browse all 46379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>