Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Answered

Custom Validation Script in Go Live button is not working

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.
  • cloflyMao Profile Picture
    cloflyMao 25,198 on at
    RE: Custom Validation Script in Go Live button is not working

    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.

  • Audrey Amelia Profile Picture
    Audrey Amelia 65 on at
    RE: Custom Validation Script in Go Live button is not working

    Hi Clofly,

    I followed your steps and it works well.

    Thank you for the solution. I really appreciated.

    Regards,

    Audrey

  • Audrey Amelia Profile Picture
    Audrey Amelia 65 on at
    RE: Custom Validation Script in Go Live button is not working

    Hi Clofly,

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

    Thank you for your advice.

    Audrey

  • Verified answer
    cloflyMao Profile Picture
    cloflyMao 25,198 on at
    RE: Custom Validation Script in Go Live button is not working

    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
    Audrey Amelia 65 on at
    RE: Custom Validation Script in Go Live button is not working

    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

  • cloflyMao Profile Picture
    cloflyMao 25,198 on at
    RE: Custom Validation Script in Go Live button is not working

    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

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