Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

While executing SIL Script for reactivation of users in jira i am getting the below error

Gaurav Kumar August 23, 2023
{"code":-1,"error":"com.keplerrominfo.sil.lang.SILException","message":"SIL program '[inline source]', parse exception: Missing ';' separator in line 1 column 12 ?\nEncountered [ ([) at line 14, column 3. Was expecting: <EOF>\n","causes":["com.keplerrominfo.sil.lang.SILException- SIL program '[inline source]', parse exception: Missing ';' separator in line 1 column 12 ?\nEncountered [ ([) at line 14, column 3. Was expecting: <EOF>\n","com.keplerrominfo.refapp.sil.impl.AbstractSimpleLanguageService.interpret(AbstractSimpleLanguageService.java:184)","..........","com.keplerrominfo.sil.lang.grammar.SilParseException- Missing ';' separator in line 1 column 12 ?\nEncountered [ ([) at line 14, column 3. Was expecting: <EOF>\n","com.keplerrominfo.sil.lang.executors.DirectInterpreterExecutor.createParseError(DirectInterpreterExecutor.java:205)",".........."],"fieldErrors":{}}

 

2 answers

1 vote
Neel Mohapatra _Appfire_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 24, 2023

Hi @Gaurav Kumar 

Looks like you are trying to execute the groovy code in sil manager.

Kindly make use of below routine to activate users from csv file.

https://appfire.atlassian.net/wiki/spaces/PSJ/pages/15481241/admActivateUser

https://appfire.atlassian.net/wiki/spaces/PSJ/pages/15489831/readFromCSVFile

below is the sample code that you can use.

eg:

string [] fileContent = readFromCSVFile("users.csv", true);

for (string usr in fileContent ) {
boolean s = admActivateUser(usr); //activating users, if sucessfully activated returns tru else false
runnerLog("user " + usr +" activation status is : "+ s); //showing result in editor console

}

 
if you have latest version of power script installed you will be able to upload the csv file into the silprograms folder, just by right clicking on it. 
else you can manually move the file under silprograms.

it should look something like this.
1.jpg

then you can use the code i shared above and  make sure to check the script before clicking on green play button. if there are any errors it will show it to you .

once the code does not have any error, you can click on play button to run the script and you should see the result in the editor console.

eg:
2.jpg
you can also use printInfile routine instead of runner log,  if you want to save the output in a file.
https://appfire.atlassian.net/wiki/spaces/PSJ/pages/15489159/printInFile

Let me know if it helped!

Gaurav Kumar August 24, 2023

Hi @Neel Mohapatra _Appfire_  thank you for the detailed steps. However post checking for syntax error it was successful but while running the script it it showing below error in editor console-

 

Exception while executing SIL program '[inline source]': [SIL Error on line: 1, column: 25] File >>users.csv<< cannot be found!

 

the user.csv file contains the below details-

 

issue key,
ahmed.khan2,

Neel Mohapatra _Appfire_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 24, 2023

Hi @Gaurav Kumar ,

Looks like the script is not able to find the CSV file.

Did you make sure you have a users.csv file under silprograms folder?

the csv file should contains the user names, just to let you know key word "issue key" is not needed.

Did you try to upload the csv file? or did you place the CSV file manually into the silprograms folder?

you can also use the complete path of the file.

It is advised to use the file inside silprograms folder so that there is no  permission issue.


to check the full path of sil programs you can go to power app config and look for sil storage as shown below.

1.jpg

then you can use the complete path of the file.
eg:

2.jpg

note:
please check if the csv file has at least read permission.
please check if you have moved the file inside the silprograms folder.


You are very close to get the script working, let me know if it helped.


Gaurav Kumar August 29, 2023

Hi @Neel Mohapatra _Appfire_ 

 

i have tried executing the script and see that the user is getting reactivated successfully.

 

Thanks you for all your efforts in helping me with the script creation.

 

Thanks-

Gaurav

0 votes
Neel Mohapatra _Appfire_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 23, 2023

Hi @Gaurav Kumar 

the error says 

Missing ';' separator

which could mean that some line of code is not ending properly and you may need to add ; at the end.

If you can share the code that you are trying to execute, that would help to understand the issue better.


Gaurav Kumar August 23, 2023

Hi @Neel Mohapatra _Appfire_  Please find the details below. Please help with the execution of the below code

 

import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.scriptrunner.runner.util.userMessageutil

def userManager = ComponentAccessor.userManager

//Read the username from the file

def username = new File (".../.../.../.../inputfile.csv").test.trim()

//Find the user by username

def user = UserManager.getuserbyName(username)

if(user) {

//Reactivate the user
user.setActive(true)
usermanager.updateuser(user)


return "User ${username} has been reactivated."
} else {

return "user${username} not found."

}

Amelie Winkler _Appfire_
Atlassian Partner
August 23, 2023

Hi @Gaurav Kumar , @Neel Mohapatra _Appfire_ is correct – it seems like you're missing the ";" symbol after reactivated.".

Try the following:

return "User ${username} has been reactivated.";
} else {

Gaurav Kumar August 23, 2023

Hi @Amelie Winkler _Appfire_  tried to execute the script still getting the below error-

 

SIL program '[inline source]', parse exception: Missing ';' separator in line 1 column 12 ? Encountered ( (() at line 14, column 3. Was expecting: <EOF>

Gaurav Kumar August 23, 2023

Hi @Amelie Winkler _Appfire_  please find the complete log details-

 

{"code":-1,"error":"com.keplerrominfo.sil.lang.SILException","message":"SIL program '[inline source]', parse exception: Missing ';' separator in line 1 column 12 ?\nEncountered ( (() at line 14, column 3. Was expecting: <EOF>\n","causes":["com.keplerrominfo.sil.lang.SILException- SIL program '[inline source]', parse exception: Missing ';' separator in line 1 column 12 ?\nEncountered ( (() at line 14, column 3. Was expecting: <EOF>\n","com.keplerrominfo.refapp.sil.impl.AbstractSimpleLanguageService.interpret(AbstractSimpleLanguageService.java:184)","..........","com.keplerrominfo.sil.lang.grammar.SilParseException- Missing ';' separator in line 1 column 12 ?\nEncountered ( (() at line 14, column 3. Was expecting: <EOF>\n","com.keplerrominfo.sil.lang.executors.DirectInterpreterExecutor.createParseError(DirectInterpreterExecutor.java:205)",".........."],"fieldErrors":{}}
Gaurav Kumar August 29, 2023

Hi @Neel Mohapatra _Appfire_ , thanks for all your support.  We need to link the script for user reactivation with a jira board user story so that whenever a request comes for user reactivation the script takes the user details(deactivated user) via function calls from the user story and then activates it automatically when the ticket moves to in progress state from assigned state.

 

Can you help me with the steps and documentation for it if possible.

 

Thanks-

Gaurav

Gaurav Kumar August 30, 2023

Hi @Neel Mohapatra _Appfire_   Can you please assist on this?

Neel Mohapatra _Appfire_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 31, 2023

Hi @Gaurav Kumar 

Yes , that can be done simply by adding the script in the post function of assigned transition.

if you have to have the user details in the custom field, then instead of csv file you can use the field to get the user details.

string usr = customfield_name;


admActivateUser(usr); //activate user
 

in the post function of the transition, please select the power script SIL post function and then select the above saved sil script.

test.jpg
 
Every time the transition happens, the script will take the user from the custom field and then try to activate it.

Let me know if it helped or if you have any other scenario.



Gaurav Kumar September 1, 2023

Hi @Neel Mohapatra _Appfire_ 

 

Thanks for the detailed steps.

 

i have tried to check for syntax check but in the script but it is throwing error.

where do i need to add the fields in the below script

string [] fileContent = readFromCSVFile("users.csv", true);

for (string usr in fileContent ) {
boolean s = admActivateUser(usr); //activating users, if sucessfully activated returns tru else false
runnerLog("user " + usr +" activation status is : "+ s); //showing result in editor console

}

Is it possible to test it in Jira local before adding it in workflow and trying to execute it via User stories.

 

Does the custom field function take values from the description field in the User stories to activate the users?

Gaurav Kumar September 4, 2023

Hi @Neel Mohapatra _Appfire_   Any thoughts on it?

Neel Mohapatra _Appfire_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 5, 2023

Hi @Gaurav Kumar ,

As I understand from your requirement, you want to activate the users when the ticket(jira issue) moves to "in progress" state.

to activate the user , you will first need to get the user details.

in our previous example, we were using the csv file to get the user details.

now that you want to automate the process, I assume that the user details is somewhere available in the ticket.

custom field can be of many types, description is a system field.

We can read the description field with the sil script and but there could many other values with the user details in the description field.

if your description field only has the user value it will be easy to read the field and then activate the user.

else it will be very difficult for the script to understand the username from all the values which is mentioned in the description.

I suppose your ticket contains user details in the description, therefore it could be difficult to get the user details.

can you answer the below:
1) Does user details which you want to activate is stored in any other field other than description? if yes, please share the type of field.

2) If the user details are mentioned in the description field, Does the description field has a predefined format where the user details are entered?
can you share the sample data of description field and which value you want to activate.


Suggest an answer

Log in or Sign up to answer