Return a number instead of a value

Hello every one!
I’m coding PHP Laravel to do some changes in my custom fields.
I want to copy the data from organizations to custom fields in the deal, and I set a custom field with
a unique option type with two values, “YES”,“NO”.
So “No” is when the value is “null” for this case there are no problems, But the problem is when it’s “YES” it returns “1067” on the field instead of “YES”.
This is my code :

$fields[] = $client->dealFields()->find(12784)->getData();
        $fields[] = $client->dealFields()->find(12785)->getData();

        $temp = null;
        foreach ($fields[0]->options as $row)
            $temp[] = ["id" => $row->id, "label" => $row->label];

        $options[] = $temp;
        $temp = null;
        foreach ($fields[1]->options as $row)
            $temp[] = ['id' => $row->id, 'label' => $row->label];

        $options[] = $temp;

        for ($i = 0; $i < sizeof($deals); $i++) {
            $payment = $client->organizations()->find($deals[$i]->org_id)->getData()->{"ec84d1f7925ba13523f929fecb53bc337f00a97b"};

            for ($j = 0; $j < 2; $j++) {
                $key = null;
                for ($k = 0; $k < sizeof($options[$j]); $k++) {
                    if ($options[$j][$k]["label"] == $payment) {
                        $key = $options[$j][$k]["id"];

                if ($key == null) {
                    $options[$j][] = ["label" => $payment];

                    $fields[$j] = $client->dealFields()->update($fields[$j]->id, ["options" => $options[$j]])->getData();

                    $temp = null;
                    foreach ($fields[$j]->options as $row)
                        $temp[] = ["id" => $row->id, "label" => $row->label];
                    $options[$j] = $temp;

                    $key = $options[$j][sizeof($options[$j]) - 1]["id"];

                $client->deals()->update($deals[$i]->id, [$fields[$j]->key => $key]);

I need some help to fix it ;
THANK YOU :smiley:

Hi @younes_khalfi
Welcome to the community and for sharing the code snippet.
It could be the case that you are receiving the ID (as expected) for the custom field option than the actual value. You can find the IDs corresponding to the options by querying the organization fields endpoint

This topic was automatically closed after 9 days. New replies are no longer allowed.