Hi John – With javascript are you able to access the html tags (DOM objects)? what I am trying to achieve is generate a chart and then render it with an HTML tag (<DIV>). Is that possible in Notes field? How are you able to load a file inot the Notes field. I don’t see that feature?
Hi Sam – Have you written any sample code using the new Script Folder Access? could I load js files with the feature?
thanks,
rocky
I think what you want done can be achieved by a script field that looks at the contents of another field to see what value it has in it and then outputs a result.
There was a post on how to link fields when typing which focused on mapping a value from one field into another one. It used switch statements via Javascript but a similar one could be done with nested if statements with Javascript regular expressions to match entries and values.
Then the script field would display the same content on all records where the other text field contained a particular value.
Hi Sam,
Sorry to ask you again
I made several tests with your form
But I think I didn’t get it all or something’s not working
We have three forms: Magazine, Keywords, Articles
The main form is Magazine so it is in this one that I enter all my articles with:
The title of the magazine
The number
The date of publication
Keywords
The pages
Subject title
It is in the Articles table (link) that I must enter, isn’t it?
What is the Article table for (Table0 in the form?
When I run the script, the new records are not added in the Keywords form (only in the Articles form)
Did I do something stupid or change something without realizing it?
Another question :
For the Magazine Month field (calculation type), I cannot display it in a date format type MMMM YYYY
To sum up, the Keywords form is the most useful to me.
It allows me to consult the table which lists all the magazines for a specific keyword.
I have attached the 3 forms that you had made at the beginning.
Thanking you for the time and the help you give me
Attachments:
You must be
logged in to view attached files.
Here is a the function I call. Basically I call another script that adds information to the markdown field. The reason I have the script broken out is that I call applyStockPerformance(fldStockPerformanceKey,fldTradeId); multiple locations (i.e Upload Load process, refresh layout and when I’m expiring options module). Again thanks for the idea.
document.getFormNamed('Script.Manager').runScriptNamed('Globals');
document.getFormNamed(FORM_TRADE_SUMMARY).runScriptNamed('Apply.Stock.Performance');
/**
*
* Refreshes the Trade Summary Layout. This module is called by the button that
* that is on the Trade Summary Layout
*
*/
function refreshTradeSummaryLayout() {
let fldTradeId = record.getFieldValue('fld-5399c8a67ee44fc18239a890a5102d41');
let fldStockPerformanceKey = record.getFieldValue('fld-f5b68ce9937d4958a516862b502933b0');
//-- Run modules to update Markdown fields in Trade Summary form
applyStockPerformance(fldStockPerformanceKey,fldTradeId);
form.saveAllChanges();
}
refreshTradeSummaryLayout();
Hi Rocky,
Script fields cannot display images, but you can write a script to add an image to a Photo field. There’s an API for getting an image from a URL:
record.addPhotoFromUrlToField(image_url, photo_field_id);
Hi Team – Is it possible to load an image into a script field. I have a Trade Summary form and want to get the first image from my link form (Trade Journal form) and display it within my Trade Summary Layout form. Not sure if I am using the correct image properties, but here is a small sample of my code in the script field.
let linkTradeJournal = record.getFieldValue('fld-310f922806294fcda6e0215c29b7b1ff');
for (rec in linkTradeJournal){
//-- Only need the first entry of the record set
let img = linkTradeJournal[rec].getFieldValue('fld-f2a5d1f9d7cc4ef9bc96e25f3aa3497b');
return img[0].mimtype;
}
thanks,
rocky
Thanks. Yes, it did take a lot of time, and sometimes I have to think back to work out how it calculates, if I want to make a change. So far, once I got it working, I left it alone. If it ain’t broke, don’t try to fix it! If anyone can find a shorter way to calculate it, that would be good.
Thanks for the script version. Although I used to code regularly in Visual Basic, I’ve never got into scripting. I must try it some time. I fear it won’t be for a while, as we are trying to downsize our housing at present, so I don’t have a lot of time for computing!
With best wishes, John
A simple field type of “button” that ran a script (like the Script field type) would work wonders for this (and other uses). The multi-column grid view could show the button with its text label on it.
My current play looks like the attached. I put the button on a different layout and put that layout on the bottom split of the view.
Attachments:
You must be
logged in to view attached files.
Hi Rocky,
This is supported, but you need to get the Script object first.
Try this:
var script = form.getScriptNamed("My Script");
var scriptName = script.name;
console.log(scriptName);
See if that works for you.
But also, there is a built-in variable called scriptName that you could simply access to get the name of the currently executing script.
So just try:
console.log(scriptName);
Hi Brendan – I know I can hit the refresh button to recalculate all my formulas on a form or have my transaction appear in a search. Is it possible that you could expose the recacluate feature in the Javascript API. The reason I am asking is that about 95% of my data entry is done thru data uploades and it would be nice to execute the recalculate feature in the code. So that I don’t need to remember to hit the recalculate button all the time.
thanks,
rocky
Hi Team – trying to use the following snippet of code to get the script name var scriptName = script.name; but I keep geting message “Can’t find Variable: script” Is the script API no longer supported?
thanks,
rocky
I must have missed escaping the backticks when I originally posted it, the forum catches them and turns them into the code tags even though it’s inside a code environment already. @daniel_leu is correct though, my scripts are all up on GitHub so you can grab them there.
I would download the latest version of the script from Sam’s github repository: https://raw.githubusercontent.com/pasamio/tftools/master/scripts/js/logger.js
Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks
Hi Sam – Reallly like your Looger module. I’m getting an error when trying to compile it. It seems it does not like the “code” tag. Am I missing someting? or did the “code” tag get placed when you copied the script to the site? Also, Have you mofified the script since this last post? If so, can you attach the script?
it failing here.
this.logMessage( <code>Caught error: "${error}" at ${error.line}, ${error.column} </code>);
thanks,
rocky
Brendan,
Thank you very much for adding the following:
Added list of form layouts to the Layout menu. Changes dynamically depending on selected form.
I hope you can continue to improve this so that it will be possible to be more easily change the order of layouts (in a similar way to Forms) which is currently not possible and also introduce a categories feature (in a similar way too to Forms).
There are two specific queries on the update:
Added new Markdown field type. This is a “note” type field where you can type in markdown and Tap Forms will render it for you.
Is the flavour of Markdown you are using the most basic kind? That is not MultiMarkdown or any variant (such as supporting tables)?
Added script functions to let you get and select custom layouts.
Could you provide the syntax for these new script functions as they do not appear present on this page https://www.tapforms.com/help-mac/5.3/en/topic/javascript-api.