Select to view content in your preferred language

Arcade Table Not Running Function

218
3
Jump to solution
11-05-2024 07:53 AM
Labels (1)
Ed_
by MVP Regular Contributor
MVP Regular Contributor

Hello all, good morning, hope all is well 🙂, so I have added three functions in an Arcade script for a table.

The script itself is not flagging any errors, but the output window say "Unable to execute Arcade script"

How can I fix this?

Whole code:

// Color severity values
function returnColorS(value){
  return When(
    value == "Minor", "#dedede",
    value == "Significant", "#C1C1C1",
    value == "Major", "#D18E8E",
    value == "Severe", "#D17578",
  )
}

function showIconS(value){
  return IIF(value == "Severe", "Alert",'')
}

function showIconL(value){
  return IIF(value == "Likely", "Alert",'')
}

return {
  cells: {
    name: {
      displayText : $datapoint.name,
      textColor: '',
      backgroundColor: '',
      textAlign: 'left',
      iconName: '',
      iconAlign: '',
      iconColor: '',
      iconOutlineColor: ''
    },
		
    home_address: {
      displayText : $datapoint.home_address,
      textColor: '',
      backgroundColor: '',
      textAlign: 'left',
      iconName: '',
      iconAlign: '',
      iconColor: '',
      iconOutlineColor: ''
    },
		
    cell_phone: {
      displayText : $datapoint.cell_phone,
      textColor: '',
      backgroundColor: '',
      textAlign: 'left',
      iconName: '',
      iconAlign: '',
      iconColor: '',
      iconOutlineColor: ''
    },
		
    email_address: {
      displayText : $datapoint.email_address,
      textColor: '',
      backgroundColor: '',
      textAlign: 'left',
      iconName: '',
      iconAlign: '',
      iconColor: '',
      iconOutlineColor: ''
    },
		
    date_and_time: {
      displayText : Text($datapoint.date_and_time),
      textColor: '',
      backgroundColor: '',
      textAlign: 'left',
      iconName: '',
      iconAlign: '',
      iconColor: '',
      iconOutlineColor: ''
    },
		
    who_is_submitting_the_potential: {
      displayText : $datapoint.who_is_submitting_the_potential,
      textColor: '',
      backgroundColor: '',
      textAlign: 'left',
      iconName: '',
      iconAlign: '',
      iconColor: '',
      iconOutlineColor: ''
    },
		
    what_government_level: {
      displayText : $datapoint.what_government_level,
      textColor: '',
      backgroundColor: '',
      textAlign: 'left',
      iconName: '',
      iconAlign: '',
      iconColor: '',
      iconOutlineColor: ''
    },
		
    what_kind_of_hazard_are_you_rep: {
      displayText : $datapoint.what_kind_of_hazard_are_you_rep,
      textColor: '',
      backgroundColor: '',
      textAlign: 'left',
      iconName: '',
      iconAlign: '',
      iconColor: '',
      iconOutlineColor: ''
    },
		
    please_specify_the_type_of_haza: {
      displayText : $datapoint.please_specify_the_type_of_haza,
      textColor: '',
      backgroundColor: '',
      textAlign: 'left',
      iconName: '',
      iconAlign: '',
      iconColor: '',
      iconOutlineColor: ''
    },
		
    how_severe_could_the_injury_to: {
      displayText : $datapoint.how_severe_could_the_injury_to,
      textColor: '',
      backgroundColor: returnColorS($datapoint.how_severe_could_the_injury_to),
      textAlign: 'left',
      iconName: showIconS($datapoint.how_severe_could_the_injury_to),
      iconAlign: '',
      iconColor: '',
      iconOutlineColor: ''
    },

    what_is_the_probability_that_in: {
      displayText : $datapoint.what_is_the_probability_that_in,
      textColor: '',
      backgroundColor: '',
      textAlign: 'left',
      iconName: showIconL($datapoint.what_is_the_probability_that_in),
      iconAlign: '',
      iconColor: '',
      iconOutlineColor: ''
    },
		
  }
}

 

 Functions and where there are being used in the script:

// Color severity values
function returnColorS(value){
  return When(
    value == "Minor", "#dedede",
    value == "Significant", "#C1C1C1",
    value == "Major", "#D18E8E",
    value == "Severe", "#D17578",
  )
}

function showIconS(value){
  return IIF(value == "Severe", "Alert",'')
}

function showIconL(value){
  return IIF(value == "Likely", "Alert",'')
}


how_severe_could_the_injury_to: {
      displayText : $datapoint.how_severe_could_the_injury_to,
      textColor: '',
      backgroundColor: returnColorS($datapoint.how_severe_could_the_injury_to),
      textAlign: 'left',
      iconName: showIconS($datapoint.how_severe_could_the_injury_to),
      iconAlign: '',
      iconColor: '',
      iconOutlineColor: ''
    },

    what_is_the_probability_that_in: {
      displayText : $datapoint.what_is_the_probability_that_in,
      textColor: '',
      backgroundColor: '',
      textAlign: 'left',
      iconName: showIconL($datapoint.what_is_the_probability_that_in),
      iconAlign: '',
      iconColor: '',
      iconOutlineColor: ''
    },

 

Question | Analyze | Visualize
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

One issue is the When function doesn't have a default value. When I remove that from my test, I get the "Unable to execute" message

 

function returnColorS(value){
  When(
    value == "Minor", "#dedede",
    value == "Significant", "#C1C1C1",
    value == "Major", "#D18E8E",
    value == "Severe", "#D17578",
    "#f00000"
  );
}

Snag_5270ac.png

 

View solution in original post

3 Replies
Ed_
by MVP Regular Contributor
MVP Regular Contributor

Good morning @KenBuja hope all is well, any help with this will really appreciated, cheers 🙂

Question | Analyze | Visualize
0 Kudos
KenBuja
MVP Esteemed Contributor

One issue is the When function doesn't have a default value. When I remove that from my test, I get the "Unable to execute" message

 

function returnColorS(value){
  When(
    value == "Minor", "#dedede",
    value == "Significant", "#C1C1C1",
    value == "Major", "#D18E8E",
    value == "Severe", "#D17578",
    "#f00000"
  );
}

Snag_5270ac.png

 

Ed_
by MVP Regular Contributor
MVP Regular Contributor

yup that worked like charm 🙂 you are the best 😎 thank you for the super quick response 

have a nice day and week ahead 🙂

Question | Analyze | Visualize
0 Kudos