AnsweredAssumed Answered

Lock down all the fields in Quote line time conditionally

Question asked by Vijayakumar S on Apr 10, 2019
Latest reply on Apr 10, 2019 by André Lopes

Hi,

 

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

 

Quote Line Item is nothing but a Product, so 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")

                                               )', 
                  ),
         );
}

 

While edit the Quote Line Item it will make all the fields as read only except the "quantity" field

 

 

See the above image. while edit the QLI I am unable to make the "quantity" field as read only

Thanks

Outcomes