AnsweredAssumed Answered

Lock down all the fields in Quote line time conditionally

Question asked by Vijayakumar S on Apr 3, 2019

Hi,

 

I am trying to make all the fields in Quote Line Item read only when the Quote stage is "Invoiced/Credited"

 

For that I have created a file src/custom/modules/Products/metadata/dependencydefs.php

 

Here my code

 

<?php

$dependencies['Products']['read_only_fields'] = array();
 $fields = array(
       'product_template_name',
       'show_description',
       'display_line_item',
       'discount_price',
       'discount_per_unit_c',
       'quantity',
);

$dependencies['Products']['read_only_fields'] = array(
         'hooks' => array("all"),
         'trigger' => 'or(equal(related($quotes,"quote_stage"),"Invoiced"),                                  equal(related($quotes,"quote_stage"),"Credited")

                                )',
         'onload' => true,
         'actions' => array(),

);

foreach ($fields as $field) {
         $dependencies['Products']['read_only_fields']['actions'][] = array(
                  'name' => 'ReadOnly', 
                  'params' => array(
                        'target' => $field,
                         'value' => 'or(equal(related($quotes,"quote_stage"),"Invoiced"),                                                                                                       equal(related($quotes,"quote_stage"),"Credited")

                                               )', 
                  ),
         );
}

This code will make all the fields which I have mentioned in the $fields => array() except the 'quantity' field.

 

Any idea to make all the fields as read only ?

 

Thanks

Outcomes