Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Suggested answer

I wrote a code in table level for validation , but when i open table in browser the validation is triggering at second instance but not at first instance. what should i do?

(0) ShareShare
ReportReport
Posted on by 64

pastedimage1679573202004v1.png

there is a unique combo between event id and ticket id ,if the combo repeats the validation should throw at 1st instance when selecting ticket id.but the validation is triggered when i select the T1 twice.

  • gaya3 killy Profile Picture
    gaya3 killy 64 on at
    RE: I wrote a code in table level for validation , but when i open table in browser the validation is triggering at second instance but not at first instance. what should i do?

    but i wrote the same method with 3 arguments as below.its working fine.

    -----------------------------------

    public static boolean RecordExist(Event_ID  _eventid,Agent_ID  _agentid ,TicketId _ticketid)

       {

           AgentTicketAllocatedTable  agentticketallocated;

           select agentticketallocated where agentticketallocated.Event_ID == _eventid &&

               agentticketallocated.Agent_ID == _agentid && agentticketallocated.TicketId == _ticketid;

           {

               if(agentticketallocated.RecId)

               {

                   info('@EM:EM092');

                   return false;

               }

               else

               {

                   return true;

               }

           }

       }

       /// <summary>

       ///

       /// </summary>

       /// <param name = "_fieldIdToCheck"></param>

       /// <returns></returns>

       public boolean validateField(FieldId _fieldIdToCheck)

       {

           boolean ret;

           ret = super(_fieldIdToCheck);

           switch(_fieldIdToCheck)

           {

               case(fieldNum(AgentTicketAllocatedTable,TicketId)):

                       AgentTicketAllocatedTable::RecordExist(this.Event_ID,this.Agent_ID,this.TicketId);

                   break;

           }

           return ret;

       }

  • gaya3 killy Profile Picture
    gaya3 killy 64 on at
    RE: I wrote a code in table level for validation , but when i open table in browser the validation is triggering at second instance but not at first instance. what should i do?

    thank you

  • gaya3 killy Profile Picture
    gaya3 killy 64 on at
    RE: I wrote a code in table level for validation , but when i open table in browser the validation is triggering at second instance but not at first instance. what should i do?

    thank you

  • Suggested answer
    Mohit Rampal Profile Picture
    Mohit Rampal 12,552 Super User 2024 Season 1 on at
    RE: I wrote a code in table level for validation , but when i open table in browser the validation is triggering at second instance but not at first instance. what should i do?

    Hi, you can create a table index, add both fields and set Allow duplicate to No. This way you don't have to write any code.

    And in your code, you have created static method for same table which is not required.. A simple select first only statement to check if eventId and TicketId exists will do. However, you can still consider unique index instead of code.

  • Suggested answer
    GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: I wrote a code in table level for validation , but when i open table in browser the validation is triggering at second instance but not at first instance. what should i do?

    You need to return the Boolean value to validate method. Like below.

    Case(fieldnum(TicketPriceTable, TicketId)):
        ret = TicketPriceTable::RecordCheck(this.EventId,this.TicketId);
        break;

    Thanks,

    Girish S.

  • gaya3 killy Profile Picture
    gaya3 killy 64 on at
    RE: I wrote a code in table level for validation , but when i open table in browser the validation is triggering at second instance but not at first instance. what should i do?

    yes, warning is thrown after selecting multiple times

  • gaya3 killy Profile Picture
    gaya3 killy 64 on at
    RE: I wrote a code in table level for validation , but when i open table in browser the validation is triggering at second instance but not at first instance. what should i do?

    pastedimage1679574585260v1.pngpastedimage1679574597347v2.png

    i wrote static method and called it in the validate field method

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: I wrote a code in table level for validation , but when i open table in browser the validation is triggering at second instance but not at first instance. what should i do?

    Hi,

    Are you saying that waring is throwing after selecting TicketId multiple times?

    Can you tell me in which method did you add the validation?

    Thanks,

    Girish S.

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

Announcing Our 2025 Season 1 Super Users!

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

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,965 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,817 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans