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)

Check value of an opportunity field via javascript 2016

(0) ShareShare
ReportReport
Posted on by 410

Overall, I am trying to progress the Business process flow to the next stage (or better, to the stage I want) when a certain field (a custom status field) is a specific value, e.g. "Pending"

I've been looking at the Client API help and know how to use at least:

Xrm.Page.data.process.moveNext();

I see people recommending to use the Xrm.Page.getAttribute("fieldname"), but none of my fields are available under the getAttribute.

The specific status field I want to check is under the business process flow and also just on the page.

Question 1) How do I correctly use the getAttribute function and then use the .getValue() on it?

Question 2) It would be nicer to use the .setActiveStage() function over .moveNext(). How do I properly use the setActiveStage?

Thanks!

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Haansi Profile Picture
    1,433 Moderator on at

    [quote user="HodgesW"]

    I see people recommending to use the Xrm.Page.getAttribute("fieldname"), but none of my fields are available under the getAttribute.

    [/quote]

     

    Are fields on form ? If I m correct in order to access fields they should be on in the form body.

     

     

    For Q1 you can hock attribute and read value from it:

     

    var tempAttributeName = Xrm.Page.getAttribute("CRMAttributeName");

    var attributeValue = tempAttributeName.getValue(); 

     

    or can directly read value from it: 

     

    var attributeValue = Xrm.Page.getAttribute("CRMAttributeName").getValue();

     

    For details please see: https://msdn.microsoft.com/en-us/library/jj602964.aspx#BKMK_AccessingAttributes

     

     

    Regarding Q2 .moveNext() and .setActiveStage() have a little difference in functionalities. Using .setActiveStage() you can set a completed stage as active, moveNext() will cause business process flow to the next stage. Please see the following links for details and usage examples.

     

    http://www.powerobjects.com/2015/10/13/business-process-flows-and-javascript/

    https://msdn.microsoft.com/en-us/library/dn817878.aspx

  • Suggested answer
    ShahXu Profile Picture
    1,515 on at

    for getAttribute : field should be on form. if it is available on form then it should be retrieved.

  • Suggested answer
    SergiiChvyr Profile Picture
    on at

    Hello there,

    1) If your field is in BPF, then the name of the attribute should be prepended by "header_process_", then followed by attributename. Another thing is that you can only get a control and get an attribute from it. Like that:

    Xrm.Page.getControl("header_process_attributename").getAttribute().getValue()

    2) It wound not be nicer. You can switch to the next stage only by moveNext().  setActiveStage() allows you to activate any of previous valid stages

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