Hy i se in javascript Api this:
form.deleteRecord(someRecord);
Can you telo me a little ex?
There is also a form.selectRecord(someRecord)
I dont understand what insert in someRecord
In a script loop i want delete single record
Thank
form.selectRecord(someRecord)
is for telling Tap Forms to select a record. It’s useful when you use JavaScript to add a record to your form.
For deleting a record, you need to get the record first before you can delete it.
If you want to delete a single record in a loop, you have to first get the records from the form. Then loop through them, check the record to see if it’s the right one to delete, then call the function to delete it.
var records = form.getRecords();
var field_id = 'fld-....';
for (var index = 0, count = records.length; index < count; index++){
var aRecord = records[index];
var field_value = aRecord.getFieldValue(field_id);
if (field_value == 'some value') {
form.deleteRecord(aRecord);
}
}
form.saveAllChanges();
Something like the above should work but it has to be modified for your own form of course.
Thank you!
form.deleteRecord(records[index]);
Perfect!
Hi, when I run this script all the records are deleted in that form. I only want to delete the selected record. How can I do that?
The currently selected record is generally record
, so to delete it you just need to do form.deleteRecord(record)
.
There are some times this isn’t true, particularly when working with the script editor and link to form fields, but for simple documents it should always be true.