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 :-) 

  • Suggested answer
    Hossein.K Profile Picture
    6,646 on at
    RE: How to create two buffer values for one table in x++ ?

    Hi Vaishnav,

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

  • ergun sahin Profile Picture
    8,816 Moderator on at
    RE: How to create two buffer values for one table in x++ ?

    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
    nmaenpaa Profile Picture
    101,158 Moderator on at
    RE: How to create two buffer values for one table in x++ ?

    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.

  • Vaishnav Profile Picture
    45 on at
    RE: How to create two buffer values for one table in x++ ?

    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.

  • ergun sahin Profile Picture
    8,816 Moderator on at
    RE: How to create two buffer values for one table in x++ ?

    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
    RE: How to create two buffer values for one table in x++ ?

    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.

  • nmaenpaa Profile Picture
    101,158 Moderator on at
    RE: How to create two buffer values for one table in x++ ?

    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.

  • Martin Dráb Profile Picture
    233,017 Most Valuable Professional on at
    RE: How to create two buffer values for one table in x++ ?

    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,158 Moderator on at
    RE: How to create two buffer values for one table in x++ ?

    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?

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March 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... 294,261 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 233,017 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans