0

Trigger on a choice field (new)

i have a table with a button with this formula:

let xCurrRec := ID;
let xDiscogsRelease := 'Release Number';
let xtoken := 'Insert Your Discogs Token Here';
let url := "https://api.discogs.com/releases/" + xDiscogsRelease;
let token := xtoken;
let response := http("GET", url, {
        Authorization: "Bearer " + token,
        'Content-Type': "application/json"
    });
let artists := response.result.artists;
let xartistID := item(artists, 0).id;
'Artist ID' := xartistID;
 

that works perfectly (retrieves information in JSON from a site)

 

I would like now to set the action on a trigger of a choice field:

 

if Data = 2 then
    let xCurrRec := ID;
    let xDiscogsRelease := 'Release Number';
    let xtoken := 'Insert Your Discogs Token Here';
    let url := "https://api.discogs.com/releases/" + xDiscogsRelease;
    let token := xtoken;
    let response := http("GET", url, {
            Authorization: "Bearer " + token,
            'Content-Type': "application/json"
        });
    let artists := response.result.artists;
    let xartistID := item(artists, 0).id;
    'Artist ID' := xartistID;
end

but nothing now is working.

 

Have you got any suggestions?

As always thank you for interest and help

8 replies

null
    • Kruna
    • 1 yr ago
    • Reported - view

    Hi Francesco,

    can you try

    if number(Data) = 2 then

     

    you can also use a switch case function like:

    switch Data do

    case 1: do something

    case 2:

     let xCurrRec := ID;
        let xDiscogsRelease := 'Release Number';
        let xtoken := 'Insert Your Discogs Token Here';
        let url := "https://api.discogs.com/releases/" + xDiscogsRelease;
        let token := xtoken;
        let response := http("GET", url, {
                Authorization: "Bearer " + token,
                'Content-Type': "application/json"
            });
        let artists := response.result.artists;
        let xartistID := item(artists, 0).id;
        'Artist ID' := xartistID;
    end

      • francescostefanello
      • 1 yr ago
      • Reported - view

       thank you for your interest. Unfortunately both your solutions do not help

      • Kruna
      • 1 yr ago
      • Reported - view

      francesco.stefanellocan you pls post a sampla data base? Its easier for me to look for a solution or search the error

    • francescostefanello
    • 1 yr ago
    • Reported - view

    here it is

      • Kruna
      • 1 yr ago
      • Reported - view

      ty, I will give it a try

      • francescostefanello
      • 1 yr ago
      • Reported - view

      thanks to you

    • Kruna
    • 1 yr ago
    • Reported - view

    HI Francesco,

    Iam sorry, but I cant find a solution. Somehow the choice field doesnt trigger.

    I would say this formula is right:

     

    let xCurrRec := Nr;
    let xDiscogsRelease := 'Release Number';
    let xtoken := 'Insert Your Discogs Token Here';
    let url := "https://api.discogs.com/releases/" + xDiscogsRelease;
    let token := xtoken;
    let response := http("GET", url, {
            Authorization: "Bearer " + token,
            'Content-Type': "application/json"
        });
    let artists := response.result.artists;
    let xartistID := item(artists, 0).id;
    if text(Data) = "JSON Response" then
        'Artist ID' := xartistID
    end

     

    I tried several approaches like

    if text(Data) = "JSON Response" then
        'Artist ID' := "22"

    after trigger number 22 shows up in Artist ID field. So the formula is kind of correct.

    I tried to open an URL, it also did, but somehow your code doesnt do in the choice field.

    Maybe there is a piece of code in your formula, which can be triggered just on click, like button.

    I am not that good in Ninox, so I cant tell you for sure.

    • francescostefanello
    • 1 yr ago
    • Reported - view

    Yes, I agree, the formula is functioning well when set on a formula. Thank you for your time 

Content aside

  • 1 yr agoLast active
  • 8Replies
  • 99Views
  • 2 Following