Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Answered

comparing propsal and consumption feild in form and displaying error msg

(0) ShareShare
ReportReport
Posted on by 195

hello experts,

i have written the below code  to compare 2 feilds  in form level, so if  give same value and less than particular value m getting the same  ino msg, can any one hlp me out.

thanks in advance

public boolean modified()
{
boolean ret;
if(this.realValue()>this.leftValue())
{
info("you are entered more /less qty in consumption. pls Check again");
ret=false;
}

ret = super();

return ret;
}

below is the two feild name

pastedimage1572922437871v1.png

regards,

pradeep.

  • Martin Dráb Profile Picture
    Martin Dráb 230,458 Most Valuable Professional on at
    RE: comparing propsal and consumption feild in form and displaying error msg

    All right, so will you show us your code and explain what problem you have with it?

    It should be obvious that we can't solve an unknown problem, therefore you should have started by explaining it...

    Note that *your own* code used == operator, although your seem to want != operator. But you would immediately see this problem when you debugged your code before giving up and asking here, right?

  • pradeep M B Profile Picture
    pradeep M B 195 on at
    RE: comparing propsal and consumption feild in form and displaying error msg

    I want to display error msg if consumption  greater than  and less than proposal(just notification msg) and  if it is equal  no notification msg.

    Regards

    Pradeep

  • Martin Dráb Profile Picture
    Martin Dráb 230,458 Most Valuable Professional on at
    RE: comparing propsal and consumption feild in form and displaying error msg

    Unfortunately it's not clear what code is "this" and what problem you have with it. We can't help you unless you provide a better explanation.

  • pradeep M B Profile Picture
    pradeep M B 195 on at
    RE: comparing propsal and consumption feild in form and displaying error msg

    This code is not working properly .

    Regards,

    Pradeep

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,458 Most Valuable Professional on at
    RE: comparing propsal and consumption feild in form and displaying error msg

    Can you please test your code? You'll see that it doesn't work, because you didn't fix the bug. You don't return false when the validation fails, because what you set to ret variable is ignored, as I explained above.
    Also, are you sure you wanted to use '==' operator?

    Look at the following code (and notice how indentation makes code more readable - you just mustn't forget to use Insert > Insert Code):

    public boolean validate()
    {
        boolean ok = super();
        
        if (prodJournalBOM.BOMProposal == prodJournalBOM.BOMConsump)
        {
            ok = checkFailed("Validation message");
        }
        
        return ok;
    }

    This is how it would look like in validateField() on table:

    boolean validateField(FieldId _fieldId)
    {
        boolean ok = super(_fieldId);
    
        switch (_fieldId)
        {
            case fieldNum(ProdJournalBOM, BOMConsump):
                if (this.BOMConsump == this.BOMProposal)
                {
                    ok = checkFailed("Validation message");
                }
                break;
        }
        
        return ok;
    }

    And this if you want to do it in validateWrite(), i.e. on saving:

    boolean validateWrite()
    {
        boolean ok = super();
    
        if (this.BOMProposal == this.BOMConsump)
        {
            ok = checkFailed("Validation message");
        }
        
        return ok;
    }

  • pradeep M B Profile Picture
    pradeep M B 195 on at
    RE: comparing propsal and consumption feild in form and displaying error msg

    public boolean validate()
    {
    boolean ret;
    if(ProdJournalBOM.BOMProposal == ProdJournalBOM.BOMConsump)
    {
    warning("You are Entered more /Less qty in consumption. pls Check again");
    ret=false;
    }


    ret = super();

    return ret;
    }

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,458 Most Valuable Professional on at
    RE: comparing propsal and consumption feild in form and displaying error msg

    That's strange, because it's not validating anything. You put your code to modified() method, not to a validation method, and what you set to ret is completely ignored, because it's immediately overwritten by the value returned from super(). Was it your intention to accept invalid values and merely add a message to Infolog?

    By the way, please use Insert > Insert Code (in the rich formatting view) to paste source code. It makes it easier to read.

  • pradeep M B Profile Picture
    pradeep M B 195 on at
    RE: comparing propsal and consumption feild in form and displaying error msg

    thank you  for ur respone

    i used the below code it s working fine.

    public boolean modified()

    {

       boolean ret;

       if(ProdJournalBOM.BOMConsump == ProdJournalBOM.BOMProposal)

       {

           info("you are  entered more /less qty in consumption. pls Check again");

           ret=false;

       }

       ret = super();

       return ret;

    }

  • Martin Dráb Profile Picture
    Martin Dráb 230,458 Most Valuable Professional on at
    RE: comparing propsal and consumption feild in form and displaying error msg

    So... what problem do you have with it?

  • pradeep M B Profile Picture
    pradeep M B 195 on at
    RE: comparing propsal and consumption feild in form and displaying error msg

    sir  i have written code in table level:

    public boolean validateFieldValue(

    FieldName _fieldName,

    int _arrayIndex = 1)

    {

    boolean result;

    result = super(_fieldName, _arrayIndex);

    if ( result

    && _fieldName == fieldStr(ProdJournalBOM,ItemId)

    && !this.inventTable().isStocked())

    {

    if (this.prodTable().ProdType == ProdType::Process)

    {

    result = checkFailed("@PDS1439");

    }

    else

    {

    result =checkFailed("@SYS183557");

    }

    }

    if ( result

    && this.isProjMethodConsumed())

    {

    result = ProjInventJournalTransMapForm::construct(this).validateFieldPost(_fieldName, _arrayIndex);

    }

    if ( result && this.PdsCWInventConsump> this.PdsCWInventProposal)

    {

    info("error");

    result=false;

    }

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans