Skip to main content

Notifications

Microsoft Dynamics CRM forum
Suggested answer

Get and Compare StateCode of SalesOrder

Posted on by 160

Hi, 

I have following Requirement in CRM:

I should show an error Message on Order Form as soon as the status of Order is "submitted".

I have tried to solve this  with javascript but I've got an error:

var StateCodeValue = formContext.getAttribute ("statecode").getValue();

if(StateCodeValue == 1){

formContext.setNotification("xy ", "WARNING");

Can anybody say how can I get the value of Statecode?

Thanks in advance!

  • Elpibato Profile Picture
    Elpibato 160 on at
    RE: Get and Compare StateCode of SalesOrder

    Thank you for your response!

    Yes actually I passed the formcontext too:

    function ShowError(executionContext){

    var formContext = executionContext.getFormContext();

    var StateCodeValue = formContext.getAttribute ("statecode").getValue();

    if(StateCodeValue == 1){

    formContext.setNotification("xy ", "WARNING");

    } else {formContext.clearNotification("WARNING"); }

    }

    I've got an Error that my Webressource doesont exist. I dont know if my code line is correct for getting the StateCode value

  • Suggested answer
    Rawish Kumar Profile Picture
    Rawish Kumar 13,754 on at
    RE: Get and Compare StateCode of SalesOrder

    Hi,

    I hope you are passing the formcontext when calling this function.

    do you see any error in console?

    I would recommend you debug this script by putting "debugger;" at the begining of the code and publish.

    post that just open developer tools by pressing f12 while you are on the page & it should trigger the code

    you will be able to know which line is problem.

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

Dynamics 365 Community Update – Sep 16th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,522 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,441 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans