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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

How to create two buffer values for one table in x++ ?

(0) ShareShare
ReportReport
Posted on by 45

Consider this below example.

pastedimage1621515030110v1.png

Condition 1: When user tries to enter same id and same name it must throw an error A. So, in 2nd line that data is not acceptable.

Condition 2 : When user tries to enter same id , same name, and same place then it must throw an error B. 3rd line data not acceptable.

I'm able to code condition 2 individually using validateWrite() Method, but not able to add condition 1 inside same validateMethod().

When I'm trying to create second buffer value for Table, it is throwing error as "Variable xyz not used"  

And when I tried with  job, it is throwing error as "Error executing code: (object) has no valid runable code in method 'Job1'.Stack trace"

Please explain how to resolve these errors.

Note:- It can be done via indexing but I want to throw customized error message. So, I'm coding.

Thanks in advance :-) 

I have the same question (0)
  • nmaenpaa Profile Picture
    101,160 Moderator on at

    I think there must be some issue in your code. Do you think you could share your code so that we would be able to see what might be wrong with it?

  • Martin Dráb Profile Picture
    237,926 Most Valuable Professional on at

    I don't understand the second case. You said that it shouldn't accept "same id , same name, and same place", which is already covered by the first case. But your example doesn't match your description - ID (002) is unique there.

  • nmaenpaa Profile Picture
    101,160 Moderator on at

    Vaishnav wrote "It can be done via indexing but I want to throw customized error message. So, I'm coding."

    But, I also think that this doesn't make sense - users are already familiar with the standard error messages that unique index violations give across the system. Now they need to learn to understand different error messages in this one scenario.

    Not to forget all the time and money that's being spent working with this code. With proper unique index, the feature would already be done and Vaishnav could be providing value with next task.

  • Vaishnav Profile Picture
    45 on at

    Sorry , that was a mistake.

    Please consider below screenshot

    pastedimage1621516670555v1.png

    Hope it is clear now.

    And yes in second line "Place" is empty. So , that is different .

    Both are two different conditions.

  • ergun sahin Profile Picture
    8,826 Moderator on at

    I think the 2nd control is faulty. The fact that 3 fields are the same also means that the two fields are the same. No need for second control

  • Vaishnav Profile Picture
    45 on at

    pastedimage1621590367596v1.png

    The Place value can be empty or filled. So, it should trigger two different errors for 2nd and 3rd lines respectively.

    This is the requirement to trigger customized error messages.

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    Hi Vaishnav,

    it would really help if we could see your code.

    But generally you can use select statements to find records based on any criteria that you like.

    So if you want to check if some record in the table already has the same three fields, just write a select statement to find a record with same values in those three fields.

    If you want another check for two fields, you need to run that check after the "three field check". This is because the "two field check" will catch both cases.

  • ergun sahin Profile Picture
    8,826 Moderator on at

    Actually, I understood what you wanted to do, but I didn't understand why you could control the trio but not control the two. That's why I wanted to ask if you would like something else.

    I think you will need to share the code so we can fully understand the problem.

  • Suggested answer
    Hossein.K Profile Picture
    6,648 on at

    Hi Vaishnav,

    Why you do not use specific index in your table or data source?

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 559 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans