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;
Solved! Go to Solution.
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
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
That works, thanks!