CoreBOSBB
Help with business map - validation - 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: Help with business map - validation (/showthread.php?tid=1432)



Help with business map - validation - rslemer - 03-13-2019

I wish in payments if a specific value in my picklist another filed is a range min 01 max 10

In fact, if type of payments is a Credit Card, I wish a number of payments (another custom field ) only has a value between 01 to 10

Example

my custom field

Called "type of payments"

...
...
Credit Card
...
...

If value select in this list is Credit Card another custom field

Nr of Payments is mandatory, and a valid value is 01 to 10

..
I know is possible with a business map, but I not able to created a correct syntax


RE: Help with business map - validation - elisa.deko - 03-14-2019

Hello,

regarding to your question, I would suggest you to create a Custom Validation.
I'm writing here an example for you (pls put the right field names before testing Smile )

PHP Code:
<?php

function checkCreditCard($fieldname$fieldvalue$params$entity)
 {
 
$current_record $entity['recordid'];
 
$type $entity['typeofpayment'];
 
$pno $entity['paymentsno'];
 
$pattern '^(?:0[1-9]|10)$';
 if (
$type == "Credit Card" && preg_match($pattern$pno) && !empty($pno))
 {
 return 
true;
 }
 
 else
 
{
 return 
false;
 }
 }

?>

Then in your Validations Map you should add the following validation:
...
<field>
           <fieldname>paymentsno</fieldname>
           <validations>
               <validation>
                   <rule>custom</rule>
                   <restrictions>
                       <restriction>include/validation/checkCreditCard.php</restriction>
                   </restrictions>
               </validation>
           </validations>
       </field>
...

I hope this helps Smile


RE: Help with business map - validation - rslemer - 03-15-2019

Thanks!


RE: Help with business map - validation - rslemer - 09-25-2019

(03-14-2019, 04:49 PM)elisa.deko Wrote: Hello,

regarding to your question, I would suggest you to create a Custom Validation.
I'm writing here an example for you (pls put the right field names before testing Smile )


PHP Code:
<?php

function checkCreditCard($fieldname$fieldvalue$params$entity)
 {
 
$current_record $entity['recordid'];
 
$type $entity['typeofpayment'];
 
$pno $entity['paymentsno'];
 
$pattern '^(?:0[1-9]|10)$';
 if (
$type == "Credit Card" && preg_match($pattern$pno) && !empty($pno))
 {
 return 
true;
 }
 
 else
 
{
 return 
false;
 }
 }

?>

Then in your Validations Map you should add the following validation:
...
<field>
           <fieldname>paymentsno</fieldname>
           <validations>
               <validation>
                   <rule>custom</rule>
                   <restrictions>
                       <restriction>include/validation/checkCreditCard.php</restriction>
                   </restrictions>
               </validation>
           </validations>
       </field>
...

I hope this helps Smile

I try do that but this variable returned blank

$current_record = $entity['recordid'];


RE: Help with business map - validation - rslemer - 09-27-2019

How I ask a coreBOS to send for my function this parameters?

function checkCreditCard($fieldname, $fieldvalue, $params, $entity)

I means where I can found a documentation explains that?