How to increment a field with JSON input?


#1

Hello all. I'm having some trouble with the JSON input field , i have read all the documentation i can find yet this script does not work either syntactically , runtime error or compilation error
{

"script" : 
{
"source": """
    int i = 0;
    while(doc['id'])
    {
	    doc['id'].value - doc['id'].value + i;
	    i++;
    }
	 """
}

}

Basically what i want is to increment the last field of this data table by 1 for every row

image

Thank you


(Marius Dragomir) #2

Advanced JSON doesn't allow you to add inline scripts. You could create a scripted field with the code from inside your script and see if that fits your needs.


#3

Thank you for your insight. It worked with the scripted fields. :slight_smile:


(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.