menu

Script

A Script Field is an asynchronous field that loads into the UI after the record loads, preventing any interface slowdown.

These fields have full access to your data and can do just about anything. Use them to return full HTML payloads, for generating tables, charts, form headings, simple dashboards, and other interesting features.

This field has optional Settings as standard properties. The script must "return" text to display in field. 
Click the ?Help for a list of available functions. Use the Preview to connect to an item to view the result.

For example, we can use a Script field to display a badge sized pfp, from a source image field on a related record.

$relationship_field = "Use your field ID"
$related_table_id = Use your table id
$item_id = @{var:current-record}["data"][$relationship_field]["id"];
$o_filter = [{"field":"item_id", "compare":"EQ", "value":$item_id}];
$employees = il_loop_filter($related_table_id,$o_filter);
$img = '';

foreach($employees as $employee){
   $img = json_decode($employee["profile-image_raw"],true);
   $img_id = $img[0]["id"];
}

$img = "https://infolobby.com/file/"+$img_id;

return "<img src=\"$img\" alt=\"Badge\" style=\"border-radius: 50%; border: 2px solid #black; width:100px; \">";

The preview then shows the image from the record selected:

Still unsure how to get started?
Click the AI link to open the builder. Tell the bot what you want to build and click OK to see update the code.  Note that the bots may not always get it right.  Please double-check the results.


InfoLobby © 2024 Globi Web Solutions