CoreBOSBB
Help with business map - validation - Printable Version

+- CoreBOSBB (https://discussions.corebos.org)
+-- Forum: Support (https://discussions.corebos.org/forum-17.html)
+--- Forum: Administrator Support (https://discussions.corebos.org/forum-8.html)
+--- Thread: Help with business map - validation (/thread-1432.html)



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?