Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AshikaSuresh/4c1454aa0c2a21036b68c5b55a607e47 to your computer and use it in GitHub Desktop.
Save AshikaSuresh/4c1454aa0c2a21036b68c5b55a607e47 to your computer and use it in GitHub Desktop.
Zylker is a manufacturing organisation that uses Zoho CRM. The subform in Quotes module should filter products based on the selected Product Category. In Quotes Module, when the quantity in the Quoted Items subform exceeds available stock, the system must display an error and reset the field to null.
1. Dynamic row value based filter : onLoad Page Event with setCriteria()
2. Error message : onCellChange Event with showError()
3. Clearing cell : onCellChange Event with setValue()
//Subform - Quoted_Items - onCellChange
if (field_name == 'Quantity') {
var product = ZDK.Page.getSubform('Quoted_Items').getRow(index).getCell('Product_Name').getValue();
log(product.id);
var product = ZDK.Apps.CRM.Products.fetchById(product.id);
var quantity = product._Qty_in_Stock;
// log(product)
log(quantity)
if (value >= quantity) {
var cell_obj = ZDK.Page.getSubform('Quoted_Items').getRow(index).getCell('Quantity');
cell_obj.showError('Quantity out of stock');
cell_obj.setValue(null);
log('done')
}
}
//Page - onLoad Event
let field_obj = ZDK.Page.getSubform("Quoted_Items").getField('Product_Name');
field_obj.setCriteria("(Product_Category:equals:{{Quoted_Items.Product_Category}})", {filterOnSearch: true});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment