Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X
Hello team,
How to get an ID value of a pick filed selected? getNewFieldValue() returns String value while need to get corresponding ID.
Thanks
Solved! Go to Solution.
Solution is:
var fieldBean = bsf.lookupBean("imServerBean").getFieldBean(categoryFieldName);
var fieldMap = fieldBean.getPickFieldMappings();
print("=>>>> fieldMap is : " + fieldMap);
var newValue = delta.getNewFieldValue(categoryFieldName);
print("=>>>> newValue is : " + newValue);
var newValueInt = fieldMap.get(newValue);
print("=>>>> newValueInt is : " + newValueInt);
You have to explain your question a little bit better. Have you tried it, and what error did you get? Is it for a JavaScript trigger or different language? Can you show a piece of your code?
If it's JavaScript, it's pretty much data type independent and I think that if you do something like this, it works without data transformation:
var sb = bsf.lookupBean( "imServerBean" );
// plus code to get the delta bean in variable "ib"
var selectedID = ib.getNewFieldValue( "myPickFieldName" );
var selectedBean = sb.getIssueBean( selectedID );
Otherwise, you can use the JavaScript function parseInt.
Hello pal,
This is what I have:
- a field of type pick (1-red, 2- blue, 3 - green) at SharedRequirement level;
- a field of type FVA tied to this pick field at Requirement level with constrains to these values; (same allowed values 1,2,3) do I need this picks-fva pattern to use?
may be having picks field defined directly at Requirement level is ok for my case?
- selecting a drop down menu with values red-blue-green gives me "red"\"blue"\"green" string if use getNewFieldValue();
but I need to transform it to 1\2\3 somehow....
may be need to use direct picks field instead of FVA that tied to picks?
Regards,
I see, this is related to the other post I started replying to. I'll give you more details as soon as my work duties allow, probably within the next couple days.
For this one, you didn't answer my questions and the use case is still pretty unclear. At first glance, I'd say yo don't need to write code for that.
This is my simple code to check it things.
Solution is:
var fieldBean = bsf.lookupBean("imServerBean").getFieldBean(categoryFieldName);
var fieldMap = fieldBean.getPickFieldMappings();
print("=>>>> fieldMap is : " + fieldMap);
var newValue = delta.getNewFieldValue(categoryFieldName);
print("=>>>> newValue is : " + newValue);
var newValueInt = fieldMap.get(newValue);
print("=>>>> newValueInt is : " + newValueInt);