Painless Script Error, Creating New Variable on Data View

Hello! I am trying to create a new variable on a Data View using this painless script, but when trying to save, I am getting the generic error "Invalid Painless Script". The error also tells be to fix the highlighted errors, but there are no highlighted errors. Here is the script in question

if (doc.containsKey("ProcessCrash_split")){ 
    def processCrash = doc["ProcessCrash_split"].value; 
    int commaIndex = processCrash.lastIndexOf(","); 
    if (commaIndex > 0){ 
        emit(processCrash.substring(commaIndex+1));
        return;
    } 
    emit(processCrash);
    return;  
} 
emit("noCrash");
return;

Note: * this script works on the dev tools query editor, replacing "emit(***)" with "return ***"

Hello Mark,

The script you pasted here and the one in the image are different. Try using exactly what you pasted here.

if (doc.containsKey("ProcessCrash_split")){ 
    def processCrash = doc["ProcessCrash_split"].value; 
    int commaIndex = processCrash.lastIndexOf(","); 
    if (commaIndex > 0){ 
        emit(processCrash.substring(commaIndex+1));
        return;
    } 
    emit(processCrash);
    return;  
} 
emit("noCrash");
return;

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