Re class a field typer after script. (Web Location)

Tap Forms – Organizer Database App for Mac, iPhone, and iPad Forums Script Talk Re class a field typer after script. (Web Location)

Viewing 4 reply threads
  • Author
    Posts
  • August 26, 2019 at 6:29 AM #36512

    matt coxon
    Participant

    Hi, I’m using the vlookup script by (Sam Moffatt) great script thank you Sam!!!

    Is there a way to make a script field be a clickable URL / Hyperlink (as it would be if you had selected the “Web Site” field

    This is the script,

    Thanks Matt

    form.runScriptNamed(‘vlookup’);

    var trello_cards_id = ‘fld-a6346935a6af40d1833fad4f49958bca’;
    var tsm_rfs_id = ‘fld-b0c9111f87064a23bde75c965374e97c’;
    var short_url_id = ‘fld-7888517ad8204f5aa7a4bf926c92be15’;

    var rfs = record.getFieldValue(‘fld-e13aa1493c6f4b919f30b27cd8bc8ae9’);

    vlookup(rfs, trello_cards_id, tsm_rfs_id, short_url_id);

    August 26, 2019 at 2:04 PM #36522

    Sam Moffatt
    Participant

    You can’t make a script field clickable (would be nice, it’s on my wish list*) however as a workaround what you can do is use the script field to set the value of a web site field using record.setFieldValue(field_id, value). Then when the script is run, it’ll update the web site field to be the new value which means you can then click on that field to open the link.

    * I’d actually like a way of being able to define a custom icon for a script field and an action handler distinct from value. I think it’d be cool to have the ability to have the script field display one value but when you click it, it opens up a link or perhaps even runs a form script with a field context set. Doing all of that and getting it right is a lot of work and perhaps a little too powerful.

    August 28, 2019 at 5:21 AM #36575

    matt coxon
    Participant

    Hi Sam, thanks very much for the response, I understand what you mean but can’t seem to get the syntax correct

    Do I add the command to the main script field after the vlookup or in a new script field I played around with various but can’t seem to get it to work, but when I do I’ll need to apply it to date fields in the same scenario as the web field so will be very useful

    Thanks

    August 28, 2019 at 6:29 AM #36576

    Sam Moffatt
    Participant

    You’ll need to create a new web site field to put the data into. Then your script just needs to know what that field ID is and then set it:

    form.runScriptNamed('vlookup');
    
    var trello_cards_id = 'fld-a6346935a6af40d1833fad4f49958bca';
    var tsm_rfs_id = 'fld-b0c9111f87064a23bde75c965374e97c';
    var short_url_id = 'fld-7888517ad8204f5aa7a4bf926c92be15';
    var website_id = 'fld-yourfieldhere';
    
    var rfs = record.getFieldValue('fld-e13aa1493c6f4b919f30b27cd8bc8ae9');
    
    var website = vlookup(rfs, trello_cards_id, tsm_rfs_id, short_url_id);
    record.setFieldValue(website_id, website);
    website;
    

    Something like that should work, hopefully it makes sense. website_id is the new field you add to store the URL and make clickable, I put website into a variable so that I can use it to set and then use it as the return value for the script (kinda redundant but not harmful). You could probably hide the script field once it’s all working.

    EDIT: Updated to remove smart quotes. If you have smart quotes, things won’t work the way you expect and you’ll get errors from JavaScript. If you’re working on iOS, make sure you use the quote button above the keyboard to ensure you don’t put in smart quotes accidentally. On the Mac, it usually doesn’t input smart quotes so you’re safe there.

    August 30, 2019 at 12:44 PM #36632

    matt coxon
    Participant

    Works perfectly now , thanks very much for the further details
    Cheers ?
    Matt

Viewing 4 reply threads

You must be logged in to reply to this topic.