Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with business map - validation
#1
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
Ranieri
eCRM Web
Reply
#2
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
Reply
#3
Thanks!
Ranieri
eCRM Web
Reply
#4
(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'];
Ranieri
eCRM Web
Reply
#5
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?
Ranieri
eCRM Web
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)