Posts: 96
Threads: 13
Joined: Jan 2017
Reputation:
22
06-19-2023, 03:55 PM
(This post was last modified: 06-19-2023, 03:56 PM by inspectorflint.)
Hello:
I am developing a system for a textile company.
We have created a custom module module (Brands), which is relating to Products. The client wants that when a salesman is creating a new salesorder, depending on the brand that is selected in the sales order, the popup only shows the products of this concrete brand. (There are salesman who have several brands assigned ).
It is possible edit the query in the popup? Or do it using business maps?
Thank You!
Posts: 96
Threads: 13
Joined: Jan 2017
Reputation:
22
Thanks, Joe, for your quick response!
I am trying to do it with the List Column popup filter. This is my business map:
<map>
<originmodule>
<originname>SalesOrder</originname>
</originmodule>
<relatedlists>
<relatedlist>
<module>Products</module>
<linkfield>productname</linkfield>
<columns>
<field>
<label>Part Number</label>
<name>productcode</name>
</field>
<field>
<label>Product Name</label>
<name>productname</name>
</field>
<field>
<label>Vendor Name</label>
<name>vendor_id</name>
</field>
<field>
<label>Unit Price</label>
<name>unit_price</name>
</field>
<field>
<label>brand</label>
<name>brand</name>
</field>
</columns>
</relatedlist>
</relatedlists>
<popup>
<linkfield>productcode</linkfield>
<columns>
<field>
<label>Part Number</label>
<name>productcode</name>
</field>
<field>
<label>Product Name</label>
<name>productname</name>
</field>
<field>
<label>Unit Price</label>
<name>unit_price</name>
</field>
<field>
<label>Brand</label>
<name>cf_1267</name>
</field>
<field>
<label>Season</label>
<name>cf_1268</name>
</field>
</columns>
<conditions>
<condition>
<forfield>productid</forfield>
<value>[{"fieldname":"cf_1262","operation":"equal","value":"cf_1267","valuetype":"rawtext","joincondition":"and","groupid":"0","groupjoin":""}]</value>
</condition>
</conditions>
</popup>
</map>
The problem appears with the condition: I need that the popup query only show the products assigned to one brand, that the user select in the sales order whith the field cf_1262. In the products module, this field is the cf_1267, but it don´t works.
Also I try with the same condition value that appears in the Popup Query Conditions in the documentation:
<value>[{"fieldname":"unit_price","operation":"less than","value":"5","valuetype":"rawtext","joincondition":"and","groupid":"0","groupjoin":""}]</value>
and it dont work, too
Any idea? Thank you
Posts: 96
Threads: 13
Joined: Jan 2017
Reputation:
22
Hello.
I an trying a new aproximation to the trouble. With the business map (above) I am only adding new columns in the popup, and it works.
Next step: The custom query is working in Products.php file, with the function getQueryByModuleField,
....
elseif ($module == 'SalesOrder') {
$sql = $query_body." WHERE vtiger_productcf.cf_1267 = 10321 AND ".$query_cond;
return $adb->convert2Sql($sql, array($_REQUEST['productid']));
}
....
but I need the value of one of the fields in the sales Order. I need change the value of 10321 with the value of the cf_1262 field of the Sales Order when I am creating this sales order ( before save the register)
How Can I capture this values? Or they are disponible with any javascript function?
Thanks and happy Saturday
Posts: 1
Threads: 0
Joined: Aug 2023
Reputation:
0
Did the trick, thanks very much