Display GrappObject

Viewing 5 reply threads
  • Author
    Posts
  • July 22, 2021 at 11:07 AM #44843

    Tim Flick
    Participant

    In iOS,is there any way to display a graphic object such as a flag based upon a value in another field. Also why does the multi column view lock up on rotation from landsyto portrait

    Thanks

    Tim

    July 24, 2021 at 1:13 PM #44848

    Brendan
    Keymaster

    Hi Tim,

    You could maybe do something like that in a Script, but use Emoji’s for the flag instead of a graphic object. Although I guess depending on what you’re trying to do, just a Calculation field that looks at a value from a field and returns an Emoji flag character depending on the result.

    Something like:

    IFEQUAL(Country; "Canada"; "??"; "")

    So this says, if the value of the Country field is “Canada”, return the Canadian Flag emoji, otherwise, return nothing.

    Thanks,

    Brendan

    July 25, 2021 at 2:56 AM #44851

    Tim Flick
    Participant

    Brendan thanks much

    July 25, 2021 at 9:56 AM #44852

    Sam Moffatt
    Participant

    On the emoji front, I went looking for something that could automatically take the country and turn it into a flag, I found some sample code that used the country code to turn into the flag. I pulled that into a script and it seemed to work out ok:

    function getFlagEmoji(countryCode) {
      return countryCode.toUpperCase().replace(/./g, char => 
          String.fromCodePoint(127397 + char.charCodeAt())
      );
    }
    
    function Flag() {
    	var country = record.getFieldValue('fld-7769fdcb2a4f46a8a225db562a289359');
    	return getFlagEmoji(country);
    }
    
    Flag();
    

    Replace the field ID with your field ID, if you want to do some extra translations or mappings then you can do that in script but if you do some data wrangling this won’t be too bad. I grabbed the country code list from W3Schools and pasted it into a new form with the above script via the MCLV and it’s attached below as a Tap Forms Archive.

    Attachments:
    You must be logged in to view attached files.
    July 25, 2021 at 10:47 AM #44854

    Sam Moffatt
    Participant

    Screenshot as well, picture worth a thousand words.

    Attachments:
    You must be logged in to view attached files.
    July 26, 2021 at 3:51 AM #44862

    Tim Flick
    Participant

    what if I have multiply conditions with one text and one numeric

    thanks Tim

    July 26, 2021 at 7:28 PM #44864

    Sam Moffatt
    Participant

    Script field is Javascript so anything you can code into Javascript you can put as a condition. It’s a bit more verbose than the calculation fields but I feel a lot more flexible and expressive plus the development loop is a little easier as you can run it inside the editor and see the result (or get an error on the console from the JS interpreter).

    For each field, you need to do a record.getFieldValue to grab the value and then you can do what ever operation you need (obviously limited by Javascript).

Viewing 5 reply threads

You must be logged in to reply to this topic.