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

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

Get and Compare StateCode of SalesOrder

(0) ShareShare
ReportReport
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!

I have the same question (0)
  • Suggested answer
    Rawish Kumar Profile Picture
    13,758 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.

  • Elpibato Profile Picture
    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

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 > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 179 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 110

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 61 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans