web
You’re offline. This is a read only version of the page.
close
Skip to main content
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 

I have the same question (0)
  • Suggested answer
    nmaenpaa Profile Picture
    101,160 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!

  • Suggested answer
    Martin Dráb Profile Picture
    236,320 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.

  • nmaenpaa Profile Picture
    101,160 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.

  • 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. 

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 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++

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

  • Verified answer
    nmaenpaa Profile Picture
    101,160 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++

    Thanks for your answer,

     two.PNG

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

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 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.

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,047

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 885 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 592 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans