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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
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 70

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.

I have the same question (0)
  • GirishS Profile Picture
    27,829 Moderator on at

    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.

  • gaya3 killy Profile Picture
    70 on at

    pastedimage1679574585260v1.pngpastedimage1679574597347v2.png

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

  • gaya3 killy Profile Picture
    70 on at

    yes, warning is thrown after selecting multiple times

  • Suggested answer
    GirishS Profile Picture
    27,829 Moderator on at

    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.

  • Suggested answer
    Mohit Rampal Profile Picture
    12,565 Moderator on at

    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.

  • gaya3 killy Profile Picture
    70 on at

    thank you

  • gaya3 killy Profile Picture
    70 on at

    thank you

  • gaya3 killy Profile Picture
    70 on at

    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;

       }

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

News and Announcements

Season of Giving Solutions is Here!

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
Abhilash Warrier Profile Picture

Abhilash Warrier 836 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

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

#3
Martin Dráb Profile Picture

Martin Dráb 346 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans