Arcade formating to include if

802
2
Jump to solution
06-16-2021 01:57 PM
CCWeedcontrol
Occasional Contributor III

I need to format this Arcade code to include if statement but not sure how. The num field can be either 9 or 10 digits so I need to be able to include a statement if it's 9 digits do this or if it's 10 digits do this. How can I do this?

 

var Num;
Num = $feature.Num;

// if 10 digit run this
//var txt = Left(Num, Count(Num)-6)
//var txt1 = Right(Num, Count(Num)-4)
//OR
// if 9 digit run this
var txt2 = Left(Num, Count(Num)-5)
var txt3 = Right(Num, Count(Num)-4)

var url = "https://rec-search.Yoyo/find/search.asp?dfYear="+ text(txt2) + "&dfDocumentStart=" + text(txt3);return url;

 

0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
MVP Frequent Contributor

Something like this?

 

var Num = Text($feature.Num)
var txt1
var txt2
if(Count(Num) == 10) {
  // if 10 digit run this
  txt1 = Left(Num, Count(Num)-6)
  txt2 = Right(Num, Count(Num)-4)
} else {
  // if 9 digit run this
  txt1 = Left(Num, Count(Num)-5)
  txt2 = Right(Num, Count(Num)-4)
}

return "https://rec-search.Yoyo/find/search.asp?dfYear="+ txt1 + "&dfDocumentStart=" + txt2

 

 

Seems like you're always using the 4 left digits and the 4 right digits. Why not just do this?

 

var Num = Text($feature.Num)

var txt1 = Left(Num, 4)
var txt2 = Right(Num, 4)
return url = "https://rec-search.Yoyo/find/search.asp?dfYear="+ txt1 + "&dfDocumentStart=" + txt2

 

 

 

 


Have a great day!
Johannes

View solution in original post

0 Kudos
2 Replies
JohannesLindner
MVP Frequent Contributor

Something like this?

 

var Num = Text($feature.Num)
var txt1
var txt2
if(Count(Num) == 10) {
  // if 10 digit run this
  txt1 = Left(Num, Count(Num)-6)
  txt2 = Right(Num, Count(Num)-4)
} else {
  // if 9 digit run this
  txt1 = Left(Num, Count(Num)-5)
  txt2 = Right(Num, Count(Num)-4)
}

return "https://rec-search.Yoyo/find/search.asp?dfYear="+ txt1 + "&dfDocumentStart=" + txt2

 

 

Seems like you're always using the 4 left digits and the 4 right digits. Why not just do this?

 

var Num = Text($feature.Num)

var txt1 = Left(Num, 4)
var txt2 = Right(Num, 4)
return url = "https://rec-search.Yoyo/find/search.asp?dfYear="+ txt1 + "&dfDocumentStart=" + txt2

 

 

 

 


Have a great day!
Johannes
0 Kudos
CCWeedcontrol
Occasional Contributor III

That works, thanks!

0 Kudos