title: How to get option Set Value from Parent entity and Set that value in option set in child entity.
body: <p>I Have <code>Entity A</code> and <code>Entity B</code> with <code>N:1 Relationship</code> through lookup field called <code>lookupToB</code>.
  In <code>Entity A</code> and <code>Entity B</code> I have option set field called <code>grouping</code> with using same global option set value.
  What I need to do is, I want to set value for field <code>grouping</code> in Entity A same with field grouping B
  if the relationship exist.</p>
  
  <p>I know we can use Workflow for this, but I prefer to use javascript. </p>
  
  <p>I can get <code>name</code>,<code>id</code>and <code>entityType</code> of the Entity B and populated in one custom field in Entity A by using this code.</p>
  
  <pre><code>    //get value in lookup(Entity B)
      var LookuptoB = Xrm.Page.data.entity.attributes.get("lookuptob").getValue()[0].name;
      var LookuptoBID = Xrm.Page.data.entity.attributes.get("lookuptob").getValue()[0].id;
      var LookuptoBType = Xrm.Page.data.entity.attributes.get("lookuptob").getValue()[0].entityType;
  
      //Set value into custom field A of Entity A
      Xrm.Page.getAttribute("custom_fielda").setValue(LookuptoB + LookuptoBID + LookuptoBType);
      Xrm.Page.getAttribute("custom_fielda").setSubmitMode("always");
  </code></pre>
  
  <p>But, I cannot get any others attributes of Entity B. For example:</p>
  
  <pre><code>//Get option set value in Entity B
  var optionSetB = Xrm.Page.data.entity.attributes.get("lookuptob").getValue()[0].new_grouping;
  
  //Set option set Value in Entity A
  Xrm.Page.getAttribute("new_grouping").setValue(optionSetB);
  Xrm.Page.getAttribute("new_grouping").setSubmitMode("always");
  </code></pre>
  
  <p>I m thinking this is not correct way to get and set value for option set field <a href="https://msdn.microsoft.com/en-us/library/gg334409.aspx#BKMK_getOption" rel="nofollow noreferrer">Boolean and OptionSet Attribute methods</a>. But when I tried to get others attributes besides <code>name</code>,<code>id</code> and <code>entityType</code> of the Entity B and populated in one custom field in Entity A, the value display in that custom field in <code>undefined</code>.</p>