Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×Hello there,
Consider the following scenario.
We have 2 custom fields - "Department" & "CC Departments".
Department - Single Select Value (Transition Screen)
CC Department - Multiple Group Picker (Edit Issue Screen or View Issue Screen)
In the workflow, Department is on the self transition "Add Departments" - "New" -------> "New" where user selects the department.
We are seeking a SIL script based on the department selection on the self transition, CC Department should be updated on "Edit Screen" or "View Issue Screen".
Regards,
Sami Ahmed Shaik.
Are you looking to dynamically update the screen in real time, or update the contents of the "CC Department" field in a transition based on the value of the Department field.
Thanks for the reply @Andrew Laden .
We are looking to update the contents of the "CC Department" field only based on the value selected for the "Department" during the transition.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So it sounds like a simple switch construct would work.
switch(Department) {
case "Human Resources":
#{CC Department} = {"Security", "Applications"};
break;
case "Applications":
#{CC Department} = {Security", "IT Management"};
break;
case "Maintenance":
#{CC Department} = {"Human Resources", "Security"};
}
Save that as a sil script and execute in your post function.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the script. I tried to use the script in the following way but the script is not working.
string Department = "customfield_11705";
string CC = "customfield_12849";
switch(Department) {
case "RDS":
#{CC} = {"IRTI-RDS-Staff"};
break;
case "IFPC":
#{CC} = {"IRTI-IFPC-Staff"};
break;
case "IFCB":
#{CC} = {"IRTI-IFCB-Staff"};
break;
case "DG Office":
#{CC} = {"IRTI-DGOffice-Staff"};
break;
}
Please correct me where I am going wrong?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You are mixing up 2 different formats in SIL
Generally in SIL, there are already pre-defined variables for any custom field based on the name of the custom field. So you dont need to define "Department" as a varaible, it i already there. The catch is if the custom field name has spaces in it, in which case you have to enclose it in #{..}
So you don't need to define variables for CC and Department.
However, if you want to you can, you just have to reference the variable as %name%
So assuming your custom field is id 11705 and named "CC Department" the following would all work
customfield_11705 = {"IRTI-DGOffice-Staff"}; # field by ID number
#{CC Department} = {"IRTI-DGOffice-Staff"}; # Field by name
string ccdepartment = "customfield_11705"
%ccdepartment% = {"IRTI-DGOffice-Staff"}; # Defining a variable and referencing it.
See https://confluence.cprime.io/display/SIL/Variable+resolution for more information.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the reply, I am getting the following errors
Variable >>Department<< is not defined!
[SIL Error on line: 6, column: 28] Incompatible possible types for ATTRIB: LHS = null, RHS = [STRING[]]
Variable >>CC Departments<< is not defined!
[SIL Error on line: 9, column: 28] Incompatible possible types for ATTRIB: LHS = null, RHS = [STRING[]]
Variable >>CC Departments<< is not defined!
[SIL Error on line: 12, column: 28] Incompatible possible types for ATTRIB: LHS = null, RHS = [STRING[]]
Variable >>CC Departments<< is not defined!
for the following script
switch(Department) {
case "STI":
#{CC Departments} = {"PRES-STI-DESK"};
break;
case "Prez Office":
#{CC Departments} = {"PRES-PRO-DESK"};
break;
case "SDGs":
#{CC Departments} = {"PC-Advisor-SDGs"};
break;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thats Odd, I just tested with the following code and it ran fine.
switch(Department) {
case "TSG":
#{CC Departments} = {"Department one", "Department two"};
break;
case "Applications":
#{CC Departments} = {"Department two", "Department three"};
break;
case "Maintenance":
#{CC Departments} = {"Department one", "Department three"};
}
Are you on an old version of SIL?
try using the customfield_id format just to see if that works.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks so much & appreciate your help, the script works by using "customfield_id".
I am wondering if we have the same scenario but instead of a single selection of DEPARTMENTS if the user has to select MULTIPLE DEPARTMENTS and based on the selection of MULTIPLE DEPARTMENTS post function should add MULTIPLE GROUPS then how can we do this? Consider the below scenario requirements
TO Department --> Multi-Select Custom Field
CC Department --> Multi-Group Pickers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You are going to want to use the "elementExists" function.
So instead of using a switch..case statement, you will probably just want a set of i"if" statements.
if ( elementExists(#{Department},"STI")) {
#{CC Departments} = {"PRES-STI-DESK"};
}
Depending on how you write it you may end up matching multiple cases, so you probably want to use arrayAddElementIfNotExist to add to the CC Departments field
if ( elementExists(#{Department},"STI")) {
arrayAddElementIfNotExist (#{CC Departments},"PRES-STI-DESK");
}
That way you would get the all of the departments that should be added.
You should take some time to really read through the SIL manual at https://confluence.cprime.io/pages/viewpage.action?pageId=6560282
It gives lots of good examples to work from.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you so much. I will try the script and will share the feedback by tomorrow.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.
Register Now
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.