Search code examples
javascriptdynamics-crm-2011dynamics-crmcrmjscript

Jscript CRM Return Value


I am looking to pass a parameter from one function to another for example:

function getValueOfAttribute(field1Name) {
var attributeValue = Xrm.Page.getAttribute(field1Name).getValue();
return attributeValue;
}

function setFieldValue(field2Name, attributeValue) {
Xrm.Page.getAttribute(field2Name).setValue(attributeValue);
}

so if i called the first function passing it the field name parameter i want to then call the set function passing the second field name & the returned value from the get function

this is an example of the issue not the actual issue as i have more complex functions but still need to reference the return value.

ideally i want to but don't know if its possible to pass it in the comma separated list of parameters when adding a function.

Any ideas ?

Thank you


Solution

  • Ok with the help of glosrob(Thank you very much);

    i Created a new function called JoinFunctions

     function JoinFunctions(Join)
     {
      var resultOfFunc =  Join;
     }
    

    Calling this from form properties passing the parameter as

    FunctionName1(Parameter1, FunctionName2(Parameter2, Parameter3))
    

    For Example:

    setFieldValue("fieldname", getFieldValue("firstname"))
    

    Thank you