web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Javascript to copy field value to other field on Order Product

(0) ShareShare
ReportReport
Posted on by 1,328

I created a new field (Field B) on the Order Product entity and I want to automatically pass over the value of an existing field (Field A) to this new field (both fields are on the order product). I was told that javascript is needed for this because we are on 2015 and business rules are not yet introduced for order products, and you cannot update order product fields via workflows. I want these values to pass upon create of order products. 

Also, sometimes the values on Field A will get removed (due to our integration) but I do NOT want the value on Field B to be removed after it has been set.

Can someone please help on getting me started with this? Thanks.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    ashlega Profile Picture
    34,477 on at

    Hi,

     for the new records, your javascript might be like this:

    function Form_OnSave()

    {

     if(Xrm.Page.getAttribute("<new_field">).getValue() == null)

     {

     Xrm.Page.getAttribute("<new_field>").setValue(Xrm.Page.getAttribute("<old_field">).getValue());

      }

    }

     You can add that script as a form OnSave handler

     For the existing records, please go with Guido's answer (console app). Or you could set up an SSIS job to update existing records (but, again, might be too involved)

     Another option - having added this script, go to each an every order product.. the script will run, update the field, and you'll be able to save the record.

    PS.  However, just like we discussed before.. this will only work with the javascript if you ever open those order products in their own window (if you convert a quote, for example, this won't happen, so javascript won't run)

  • epark06 Profile Picture
    1,328 on at

    I see, then I guess the javascript won't work for this case because most order products will not be opened in their own window, and will only be viewed from the Order form after it has been converted from a quote. Does this mean plugin is the best option?

  • ashlega Profile Picture
    34,477 on at

    Yes, that seems to be how it is

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans