Note that there are some explanatory texts on larger screens.

plurals
  1. POCRM 2011 JavaScript How to access data stored in an entity passed from a lookup control?
    primarykey
    data
    text
    <p>As the question suggests, I need to find out how to access entity data that has been passed into a JavaScript function via a lookup.</p> <p>JavaScript Code Follows:</p> <pre class="lang-js prettyprint-override"><code>// function to generate the correct Weighting Value when these parameters change function TypeAffectedOrRegionAffected_OnChanged(ExecutionContext, Type, Region, Weighting, Potential) { var type = Xrm.Page.data.entity.attributes.get(Type).getValue(); var region = Xrm.Page.data.entity.attributes.get(Region).getValue(); // if we have values for both fields if (type != null &amp;&amp; region != null) { // create the weighting variable var weighting = type[0].name.substring(4) + "-" + region; // recreate the Weighting Value Xrm.Page.data.entity.attributes.get(Weighting).setValue(weighting); } </code></pre> <p>}</p> <p>As you can see with the following line using the name operator I can access my Type entity's Type field.</p> <pre class="lang-js prettyprint-override"><code>// create the weighting variable var weighting = type[0].name.substring(4) + "-" + region; </code></pre> <p>I am looking for a way now to access the values stored inside my type object. It has the following fields <code>new_type</code>, <code>new_description</code>, <code>new_value</code> and <code>new_kind</code>.</p> <p>I guess I'm looking for something like this:</p> <pre class="lang-js prettyprint-override"><code>// use value of entity to assign to our form field Xrm.Page.data.entity.attributes.get(Potential).setValue(type[0].getAttribute("new_value")); </code></pre> <p>Thanks in advance for any help.</p> <p>Regards,</p> <p>Comic</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload