javascript - Functions return undefined -
i have getglobaloptionsettextbyvalue function defined in file 1. function returns value. calling function file 2 return value seems set undefined time.
below code file 2:
var x= x|| { __namespace: true }; x.travelhistory = ( function () { //this function calculate duration , sent error message if duration greater 6 months. function travelduration( fromdate, todate ) { var crtldate = xrm.page.getcontrol( todate ); var todate = xrm.page.getattribute( todate ).getvalue(); var fromdate = xrm.page.getattribute( fromdate ).getvalue(); var optionset = xrm.page.getattribute( "dads_javascriptoptionset" ); var notification; if ( todate != null && fromdate != null ) { var temp1 = new array(); temp1 = todate.split( '/' ); // split date '/' var toyear = temp1[0]; var tomonth = temp1[1]; var temp2 = new array(); temp2 = fromdate.split( '/' ); // split date '/' var fromyear = temp2[0]; var frommonth = temp2[1]; //to year have less year if ( toyear < fromyear ) { //crtldate.setnotification( "to date needs later date." ); notification = x.common.getglobaloptionsettextbyvalue( 450640028, optionset ); crtldate.setnotification( notification ); } } } return { travelduration: function ( fromdate, todate ) { travelduration( fromdate, todate ); } }; })();
below code file 1:
var x= x|| { __namespace: true }; x.common = ( function () { var label; function getglobaloptionsettextbyvalue( value, optionsetlogicalname ) { var globaloptionset = optionsetlogicalname var entitylogicalname = xrm.page.data.entity.getentityname(); ( var = 0; < globaloptionset.getoptions().length; i++ ) { if ( globaloptionset.getoptions()[i].value == value ) { label = globaloptionset.getoptions()[i].text; break; } } return label; } return { getglobaloptionsettextbyvalue: function(value, optionsetlogicalname) { getglobaloptionsettextbyvalue(value, optionsetlogicalname); } }; })();
the problem object returned xrm.page.getattribute( "dads_javascriptoptionset" );
not contain entry value like
{ id: 450640028, text: "....whatever..." }
Comments
Post a Comment