Search Results for 'script'
-
Search Results
-
I have a basic CRM-setup. For my meeting notes I connect all of them to a customer (a related table). I would like to fetch the name from the related table (customer name) and put in to a text-field as a string. Been trying with CHatGPT with the following script but it doesn’t fill the text filed with the value:
function calc() {
// Fält-ID för det fält i relaterade tabellen som innehåller namn
var namn_id = ‘fld-e59a27d956a442f7b1995c71bffdde1e’;// Fält-ID för fältet som länkar till relaterade poster
var relaterade_falt_id = ‘fld-1234567890abcdef1234567890abcdef’;// Fält-ID för textfältet “Kundnamn”
var kundnamn_id = ‘fld-9b111db729f343629bdc9823c7af9810’;// Hämta relaterade poster
var relateradePoster = record.getFieldValue(relaterade_falt_id);// Kontrollera om det finns relaterade poster
if (relateradePoster && relateradePoster.length > 0) {
// Skapa en lista med namn från relaterade poster
var namnLista = relateradePoster.map(function(poster) {
return poster.getFieldValue(namn_id); // Hämta namn från varje relaterad post
});// Kombinera namnen till en kommaseparerad lista
var sammanstalltNamn = namnLista.join(‘, ‘);// Skriv värdet till fältet “Kundnamn”
record.setFieldValue(kundnamn_id, sammanstalltNamn);} else {
// Om inga relaterade poster finns, töm fältet “Kundnamn”
record.setFieldValue(kundnamn_id, ”);
}// Returnera ingenting (fokus är på att skriva till textfältet)
return ”;
}I’m trying to write a script that adds a pdf to a file attachment field, but addFileFromUrlToField consistently crashes Tap Forms (at least on iPadOS 18.2.1).
Here’s an example with the Tap Forms manual:function Test_Pdf() { // Field ID var file_attachment_id = 'fld-858558a7165649e6ac3bd117e17483ec'; // file url var url = "https://cdn.manula.com/user/1444/1328_16794_en_1538683502.pdf?v=20240123105634" // add new record var newRecord = form.addNewRecord(); // add to field newRecord.addFileFromUrlToField(url, file_attachment_id) } Test_Pdf(); document.saveAllChanges();
This script does create a new record, but then crashes when it tries to add the pdf. I’ve tried different files and even images that do work when using addPhotoFromUrlToField to a photo field, but Tap Forms always crashes.
Is there something special I should do to the file object before adding, or is this a bug?Topic: Scripting advice please
I have just created my first application in Tap Forms. Works well and was simple to create.
I now want to explore Scripting but need a few pointers to where to start. I can see the panel on the right of the Form screen with 3 tabs Form, Fields, Scripts.
Clearly I need to create a new Script in the Scripts tab.
Questions:
1 how do you attach a Script to a Form?
2 How do you attach a Script to a Field?
3 In each case when is the Script activated?Can your please direct me to the documentation that explains this.