Select to view content in your preferred language

Expression in Attribute Rule

614
6
Jump to solution
03-06-2024 01:41 AM
HusamJubeh
New Contributor III

Hello all
I wrote an expression without errors, but the result is incorrect.
Is the expression written incorrectly, or is there another solution?
Please help
Expression:

var path = "\\192.168.10.20\\ls\\Number\\Year";
var year = $feature.Year; // Assuming Year is a field in your dataset
var number = $feature.Number; // Assuming Number is a field in your dataset

return path + "\\" + year + "\\" + number;

HusamJubeh_1-1709717940717.png

 

HusamJubeh_0-1709717888637.png

I wrote "\\" but the result shows \, so the result is not required and the path cannot be accessed.

Please help

 

0 Kudos
1 Solution

Accepted Solutions
HildermesJoséMedeirosFilho
New Contributor III

If you need two backslashes I would try in any string "\\\\" in any string you need it.

one backslash is like a command "\n" breaks a new line "\t" is a tab, and so on.
"\\" means draw a single backslash.....if you want 2, a guess you need 4, right?

Could you try it?

View solution in original post

0 Kudos
6 Replies
GeeteshSingh07
Occasional Contributor II

@HusamJubeh, The syntax and workflow seems correct.

Could you try opening it with "Ctrl + 'Click'"? [i.e. press "Ctrl" button on keyboard & simultaneously click the mouse button].


Is '14' here a folder or any file? Could you try with any file such as PDF, PNG, JPG etc.?

If it doesn't open, could you test the same with any local drive?

0 Kudos
HusamJubeh
New Contributor III

Thanks
I clicked "Ctrl + 'Click'", but the link could not be opened.
The path is inside the organization's server. If you copy and paste it, the process is completed successfully, but the expression cannot open the link.

0 Kudos
HildermesJoséMedeirosFilho
New Contributor III

If you need two backslashes I would try in any string "\\\\" in any string you need it.

one backslash is like a command "\n" breaks a new line "\t" is a tab, and so on.
"\\" means draw a single backslash.....if you want 2, a guess you need 4, right?

Could you try it?

0 Kudos
HusamJubeh
New Contributor III

Thanks
I added "\\\\" instead of "\\", and the process succeeded.
my regards

0 Kudos
MErikReedAugusta
Occasional Contributor III

Three things:

1. Order of Parts

Line 1: Number\Year
Line 5: Year\Number

Which is the correct intention?

 

2. Intent of Script

Including my suggestion below, the three existing responses imply we have three slightly different understandings of the intent of your script.  So maybe we should start there: What should the script return?

 

3. Path Concatenation

(N.B. This assumes that having the strings "Number" and "Year" as path elements is the error.  If this is an incorrect assumption, see #2 above and let us know what you're looking for.)

Line 5 concatenates the entire path from Line 1.  You'll need to strip it down, first.  If that path is being generated automatically somewhere, you'd need to split & re-concatenate.

If the script you pasted is 100% of the script, then just remove "Number" and "Year" from Line 1.

0 Kudos
HusamJubeh
New Contributor III

Thanks
I typed "\\\\" instead of "\\" and it worked.
thank you for your comment

0 Kudos