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

Announcements

No record found.

News and Announcements icon
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!

  • Suggested answer
    Rawish Kumar Profile Picture
    13,758 on at

    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

    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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
11manish Profile Picture

11manish 108 Super User 2026 Season 2

#2
Travis South Profile Picture

Travis South 79

#3
Daniyal Khaleel Profile Picture

Daniyal Khaleel 58 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans