CoreBOSBB
Make mandatory field if we select a specific value in picklist - Printable Version

+- CoreBOSBB (https://discussions.corebos.org)
+-- Forum: Support (https://discussions.corebos.org/forumdisplay.php?fid=17)
+--- Forum: Administrator Support (https://discussions.corebos.org/forumdisplay.php?fid=8)
+--- Thread: Make mandatory field if we select a specific value in picklist (/showthread.php?tid=1540)



Make mandatory field if we select a specific value in picklist - omarllorens - 07-11-2019

Hi.

I know that we can do this using a custom validations script to my module, like you can read here:
http://corebos.com/documentation/doku.php?id=en:devel:corebos_validation

But I'm not sure if we can do this with Business Maps. Maybe with a combination of Validations and Dependency Business Maps.

Is possible?

In my case I want to make mandatory a date field when we select a concrete value form a picklist.

Thanks,

Omar.


RE: Make mandatory field if we select a specific value in picklist - elisa.deko - 07-11-2019

Hello  Omar,


I think that what you are asking for, can be done using a Validations Map. You can use an Expression for making the field mandatory or if you need to do more complicated validations go on creating a custom function.


I'm writing you here a simple example where an expression is used to make mandatory the field Codice Fiscale when the picklist field  Natura Fiscale contains the value "Ditta Individuale"


Validation Map


<map>
<originmodule>
<originname>Accounts</originname>
</originmodule>
<fields>
<field>
<fieldname>naturafisc_account</fieldname>
<validations>
<validation>
<rule>expression</rule>
<restrictions>
<restriction>Make_CF_Mandatory</restriction>
</restrictions>
</validation>
</validations>
</field>
</fields>
</map>






Expression Map (Make_CF_Mandatory)



<map>

    <expression>if ($(account_id : (Accounts) naturafisc_account)  == 'Ditta Individuale')  then (if ($(account_id : (Accounts) codice_fiscale) != '' or account_id : (Accounts) codice_fiscale) != 0) then 1 else 0 end) else 0 end</expression>
</map>





Let me know if this helps


Elisa