Skip to main content

Notifications

Announcements

No record found.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans