How to reference drop down option

Hello,

I’m still fairly new to SuiteCRM development and would appreciate some help on this. I’ve got some calculated fields that are custom coded. What I would like to do is select a specific drop down option based on a numerical calculation (i.e. if # of days = 0, then select option 1; if # of days = 10, then select option 2; etc.) The if else statements for the calculations are coded, I’m just not sure how to reference drop down options and assign a value depending on the calculation.

Thank you.

If you are using logic hooks you can use an array like:

$bean->options = (“option_1”,“option_2”,…)

If you are using Queries you can insert string like: “^Option_1^,^Optioon_2^,…”

Hope it helps

Have a look at the following thread. Maybe you can solve it that way:
https://suitecrm.com/suitecrm/forum/suitecrm-7-0-discussion/19487-how-to-create-an-associated-dropdown#67792

I appreciate both responses, unfortunately I don’t believe dynamic drop downs can solve my issue unless I’m just not thinking about it correctly. What I’m trying to do is pass a specific value to a drop down field depending on a numerical calculation. For example:

if ($days < 10)
{
$dropdown_c = option1;
}
else if ($days > 10)
{
$dropdown_c = option2;
}

I’ve tried a few different ways and just cannot figure out how to pass a value to the drop down. The drop down and it’s associated list already exist within the module. I’m trying to figure out how to pass a specific value to the drop down depending on the days calculation. (I didn’t include an example of the days calculation, but it’s a basically a days between calculation). I hope I explained that well enough.

First you need to read the documentation regarding Beans in order to understand how the system transfers data between variables. Other way you will need to create from scratch and we might not be able to help you:

https://docs.suitecrm.com/developer/working-with-beans/

The above will help you to understand how to manage information on the backed.

Now. As I mentioned on my previous post, to assign the value to a drop-down, you just need to assign value as text.


$bean->dropdown_c= "Option_1";

Check the dropdown from Studio to obtain the proper value for option.

Thanks

1 Like

@AlxGr
My apologies, it seems I left some stuff out in my haste.

I was passing to the bean and your solution worked!

My issue is that I was looking at a list view when the logic hook was set to fire on retrieval of the record or on save. Thank you so much.

Secondarily, is there a way to get this logic hook to fire at the retrieval of a list view?

I’m glad it worked.

As per the documentation:

https://docs.suitecrm.com/developer/logic-hooks/

you can use

1 Like

I was just reading that documentation and was about to reply that I’d solved it. Again thank you so much for your assistance!

No problem!!!