Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

How to show two warning message in X++

(0) ShareShare
ReportReport
Posted on by 1,215

Hi guys,

how to show in error both message for attachment and reason code at the moment in x ?

if (setup.MandatoryNotificationType == SDSNotificationType::Error)
{
    ret = ret && checkFailed("Attachment is missing. You have to attach your file then save record to submit request");
}
if(setup.ReasonCode == NoYes::Yes && setup.ReasoCodeNotificationType == SDSNotificationType::Error)
{
    if(!this.ReasonCode)
    {
        ret = ret && checkFailed("Reason code is missing. You have to attach your file then save record to submit request");
    }
}

how to show in UI while saving both message at the moment ?

Thanks 

  • Suggested answer
    nmaenpaa Profile Picture
    101,156 Moderator on at
    RE: How to show two warning message in X++

    Do you mean that you want to have multiple lines of text in a single infolog message? That's not possible as far as I know.

    In general you can add linebreaks with '\\n' into your strings, but infolog will not show them.

  • Riyas ahamed F Profile Picture
    1,215 on at
    RE: How to show two warning message in X++

    Thanks for your answer,

     two.PNG

    attachment second line i want to if its possible what should i do to change in your code ?  

  • Verified answer
    nmaenpaa Profile Picture
    101,156 Moderator on at
    RE: How to show two warning message in X++

    str errorTxt;
    boolean ret;
    
    if (validation1Fails)
    {
        ret = false;
        errorTxt = 'Validation 1 failed.';
    }
    if (validation2Fails)
        ret = false;
        errorTxt  = ' '   'Validation 2 failed.';
    }
    
    if (!ret)
    {
        checkFailed(errorTxt);
    }

  • Riyas ahamed F Profile Picture
    1,215 on at
    RE: How to show two warning message in X++

    I need to know is that possible ? could you please example for that.  

  • Suggested answer
    nmaenpaa Profile Picture
    101,156 Moderator on at
    RE: How to show two warning message in X++

    Then combine both messages in one string before printing it to infolog. Each time you call checkFailed() or info() or warning() or error() it will print a new message to the infolog.

  • Riyas ahamed F Profile Picture
    1,215 on at
    RE: How to show two warning message in X++

    Correction :

    "Attachment is missing. You have to attach your file then save record to submit request"

    "Reason code is missing. You have to attach your file then save record to submit request"

    like i want to this massage. its above my code working one by one 

    Ex: once i give it to reason code next while saving second warning   "Attachment is missing" i don't want i want to at same time UI both message. 

  • nmaenpaa Profile Picture
    101,156 Moderator on at
    RE: How to show two warning message in X++

    Ah, Martin spotted the issue and indeed you have a third condition in line 9 (if ret) and that explains why it doesn't print the second infolog.

  • Suggested answer
    Martin Dráb Profile Picture
    231,923 Most Valuable Professional on at
    RE: How to show two warning message in X++

    You call checkFailed() only if ret is true. If you don't want it, don't do it. Call it regardless of the value of ret.

    if (setup.MandatoryNotificationType == SDSNotificationType::Error)
    {
        ret = checkFailed("Attachment is missing. You have to attach your file then save record to submit request");
    }
    
    if (setup.ReasonCode == NoYes::Yes
    	&& setup.ReasoCodeNotificationType == SDSNotificationType::Error
    	&& !this.ReasonCode)
    {
    	ret = checkFailed("Reason code is missing. You have to attach your file then save record to submit request");
    }

    Make sure you learn how to use the debugger. It will help you with finding bugs in your code.

  • Suggested answer
    nmaenpaa Profile Picture
    101,156 Moderator on at
    RE: How to show two warning message in X++

    I don't see any reason why it would not show both messages if this code is executed, and if all the conditions are met so that the code execution reaches lines 3 and 9.

    When you debugged it, did it reach lines 3 and 9? If not, did you figure out why? Please share us everything that you learned while debugging it. Thanks!

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,238 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,923 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans