CoreBOSBB

Full Version: Help with business map - validation
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
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
Thanks!
(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'];
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?