Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /****************************/
- /* GRVY - Fields Select */
- /****************************/
- // Obtener el valor e id de un campo
- // Obtener las opciones de un campo
- // Setear el valor a un campo
- // Obtener el id de una opción de un campo
- // Mostrar solo ciertas opciones de las que dispone
- /************************************************************************/
- // Obtener el valor y/o id de un campo Select
- def testCf = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_10000")
- def testCfValue = ((Option) issue.getCustomFieldValue(testCf)).value
- def testCfOptionId = ((Option) issue.getCustomFieldValue(testCf)).optionId
- /************************************/
- // Obtener las opciones de un campo
- def testCf = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_10000")
- def testCfConfig = testCf.getRelevantConfig(getIssueContext())
- def testCfOptions = ComponentAccessor.getOptionsManager().getOptions(testCfConfig)
- /************************************/
- // Setear el valor a un campo
- def testCfOption = testCfOptions.findAll { it.value in ["Opcion_1"] }
- issue.setCustomFieldValue(testCf, testCfOption)
- /************************************/
- // Obtener el id de una opción de un campo
- if (ComponentAccessor.getOptionsManager().findByOptionValue(value)){
- optionId = ComponentAccessor.getOptionsManager().findByOptionValue(value)[0].optionId.toString();
- }
- /************************************/
- // Mostrar solo ciertas opciones de las que dispone
- //// Alternativa 01
- def testCfOptionsMap = testCfOptions.findAll { it.value in ["Opcion_1", "Opcion_2"] }
- selectListField.setFieldOptions(testCfOptionsMap)
- //// Alternativa 02
- def testCfOptionsMap = testCfOptions.findAll { it.value in ["Opcion_1", "Opcion_2"] }
- .collectEntries { [ (it.optionId.toString()): it.value ] }
- selectListField.setFieldOptions(testCfOptionsMap)
- /************************************/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement