One table one record only

sk227
Kilo Explorer

HI,

How to limit a table for single record entry   only ?

it should throw an error if someone try to add new record because this table already has one record.

Thanks in advance !

1 ACCEPTED SOLUTION

india
Tera Guru

Hi sarath,



Apply before business rule on insert and


in script section write this ///And in actions you can write the message whatever you feel....



(function executeRule(current, previous /*null when async*/) {




  var gr = new GlideRecord("u_one_record_table");


  gr.query();


  var cn = gr.getRowCount();


 


  if(cn>=1)


  {


        current.setAbortAction(true);




  }




})(current, previous);




Regards'


Kirtesh



Pls mark as correct/helpful/like if you think so 🙂


View solution in original post

3 REPLIES 3

srinivasthelu
Tera Guru

ohh, You can certainty do that, by a before business rule with setAbortAction and AddErrorMessage.



But, I would instead create a system property record than a table in case if you want to use that record as metadata or some sort.


india
Tera Guru

Hi sarath,



Apply before business rule on insert and


in script section write this ///And in actions you can write the message whatever you feel....



(function executeRule(current, previous /*null when async*/) {




  var gr = new GlideRecord("u_one_record_table");


  gr.query();


  var cn = gr.getRowCount();


 


  if(cn>=1)


  {


        current.setAbortAction(true);




  }




})(current, previous);




Regards'


Kirtesh



Pls mark as correct/helpful/like if you think so 🙂


sk227
Kilo Explorer

Thanks for the quick response