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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Custom Validation Script in Go Live button is not working

(3) ShareShare
ReportReport
Posted on by 65

Hi D365 Expert,

I want to add custom script in Go Live button. The script contains simple validation. The scenario like below :
If new_customfield equals null then show error message (I tried using Xrm.Navigation.openAlertDialog and formContext.ui.clearFormNotification) and not continue to become going live. The customer journey should be on draft state because the journey didn't pass from validation.
pastedimage1571048259089v8.png
But in actual, the customer journey just continue the process and become Going Live then Live.
pastedimage1571049678963v1.png
I have looking for executionObj value parameter so I can put getEventArgs().preventDefault(). But unfortunately, I didn't find executionObj value.
pastedimage1571049781369v2.png
I also put this validation in plugin PreStateDynamics but the process still continue and no rollback.
So, does anyone know how the validation can work in Go Live button?
Please advice and thank you.
I have the same question (0)
  • cloflyMao Profile Picture
    25,210 on at

    Hi Audrey,

    From your scenario: simple validation for whether a custom field be filled, you might not need a custom script to ribbon button to perform such validation.

    Instead, you could build a simple OOB business rule for it.

    1. Open Business Rule menu in form editor

    pastedimage1571122165568v1.png

    2. Set the trigger be custom field does not contain data

    pastedimage1571122212713v2.png

    3. Add Show error message action if custom field is blank

    pastedimage1571122299581v3.png

    4. Save and Active it

    5. When you click Check for errors, even thought it will say customer journey pass the error checks,

    but when you Go Live, the validation will happen before Go Live event to prevent publish.

    Error notification will display as notification bar and a text box under the field.

    pastedimage1571122381863v4.png

    Regards,

    Clofly

  • Audrey Amelia Profile Picture
    65 on at

    Hi Clofly,

    Thank you for your advice.

    Unfortunately, the business rule is still not answering what we need. If we use business rules to show the error message, it will prevent users from saving the customer journey.

    What the requirement is, users still allow save the customer journey without filling the new_customfield, but when the users want to Live the journey, the new_customfiled must be filled.

    That's why we use custom scripts to show the error message.

    Thank you

    Audrey

  • Verified answer
    cloflyMao Profile Picture
    25,210 on at

    Hi Audrey,

    As we could found that MSDynCrmMkt.MktSvcStageSwitching.goLive is command for Go Live a customer journey.

    Then(make a copy button and hide OOB button is better):

    delete original script action and only remain our own script action,

    then just call this command in our snippet:

    pastedimage1571130658034v1.png

    It works well in my environment.(It seems that CRM will find parent web resource for the OOB command automatically)

    Regards,

    Clofly

  • Audrey Amelia Profile Picture
    65 on at

    Hi Clofly,

    It looks like make sense. Well, I'll try it then will back soon.

    Thank you for your advice.

    Audrey

  • Audrey Amelia Profile Picture
    65 on at

    Hi Clofly,

    I followed your steps and it works well.

    Thank you for the solution. I really appreciated.

    Regards,

    Audrey

  • cloflyMao Profile Picture
    25,210 on at

    Hi Audrey,

    It's glad that your problem has been solved.

    Regards,

    Clofly

    If you had found the answer resolved your issue, please kindly mark as verified, it would be greatly appreciated.

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…

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 60 Super User 2026 Season 1

#2
Eugen Podkorytov Profile Picture

Eugen Podkorytov 49

#3
Jimmy Passeti Profile Picture

Jimmy Passeti 33 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans