Change Handler
The change handler is triggered for an update made in any form field containing the boolean trigger_on_change as true. The change handler can be used to either add, remove or update fields in the form depending on the input made for a certain field.
A list of attributes is passed when a function is triggered. They are listed in the table below.
Attribute name | Description |
operator | Details of the operator who is accessing the widget |
environment | Details of the environment in which SalesIQ has been accessed |
form | Details of the form object and the input values. |
target | Details of the field and the selected input that triggered the change |
Sample Code:
Copiedlisting = {{"name":"HO340WA52EIPHTFUR","title":"₹ 37,900","text":"Tiago Engineered Wood Four Door Wardrobe in Wenge Colour by HomeTown","subtext":"Shipped | Jun 28, 2020","link":"https://www.zylkerfurnitures.com/tiago-engineered-wood-four-door-wardrobe-in-wenge-colour-by-hometown/sku/HO340WA52EIPHTFUR","link_hint":"Click to view product"},{"name":"HO340FU60GNZHTFUR","title":"₹ 11,900","text":"Paris Fabric Office Chair in Black Colour by HomeTown","subtext":"Delivered | Jun 3, 2020","link":"https://www.zylkerfurnitures.com/paris-fabric-office-chair-in-black-colour-by-hometown/sku/HO340FU60GNZHTFUR","link_hint":"Click to view product"},{"name":"HO340FU28GPFHTFUR","title":"₹ 18,995","text":"Castle Engineered Wood Study Table in Highgloss White & Pink Colour by HomeTown","subtext":"Delivered | Apr 14, 2020","link":"https://www.zylkerfurnitures.com/castle-engineered-wood-study-table-in-highgloss-white-and-pink-colour-by-hometown/sku/HO340FU28GPFHTFUR","link_hint":"Click to view product"},{"name":"EA921CR91NXCHTFUR","title":"₹ 399","text":"Floral Print Polyester Door Curtain in Brown Colour by Easy Life","subtext":"Delivered | Apr 3, 2020","link":"https://www.zylkerfurnitures.com/floral-print-polyester-door-curtain-in-brown-colour-by-easy-life/sku/EA921CR91NXCHTFUR","link_hint":"Click to view product"},{"name":"HO340KD18ZKJINDFUR","title":"₹ 2,399","text":"Living Essence Oil And Vinegar Bottle With Salt And Pepper Storage 5 Pcs","subtext":"Returned | Apr 3, 2020","link":"https://www.zylkerfurnitures.com/living-essence-oil-and-vinegar-bottle-with-salt-and-pepper-storage-5-pcs/sku/HO340KD18ZKJINDFUR","link_hint":"Click to view product"},{"name":"HO340KD19FDCHTFUR","title":"₹ 8,995","text":"Vento Metal Dining Chair Set of Six in Black Colour by HomeTown","subtext":"Delivered | Mar 1, 2020","link":"https://www.zylkerfurnitures.com/vento-metal-dining-chair-set-of-six-in-black-colour-by-hometown/sku/HO340KD19FDCHTFUR","link_hint":"Click to view product"},{"name":"HO340SO62AENHTFUR","title":"₹ 43,900","text":"Rhea Fabric Three Seater sofa in Brown Colour by HomeTown","subtext":"Delivered | Jan 23, 2020","link":"https://www.zylkerfurnitures.com/rhea-fabric-three-seater-sofa-in-brown-colour-by-hometown/sku/HO340SO62AENHTFUR","link_hint":"Click to view product"}};
formValues = form.get("values");
formName = form.get("name");
response = Map();
actions = Collection();
fieldChanged = target.get("name");
fieldValueSet = formValues.get(fieldChanged);
if("returnproducts".equals(formName))
{
meta = fieldValueSet.get("meta");
fieldValue = meta.get("value");
for each listingElem in listing
{
if(listingElem.get("name").equals(fieldValue))
{
info listingElem;
actions.add({"type":"update","name":"price","input":{"type":"text","name":"price","disabled":true,"label":"Price","value":listingElem.get("title")}});
}
}
}
else if("zylkermember".equals(formName))
{
if("emailSubscription".equals(fieldChanged))
{
if(fieldValueSet.isNull())
{
// email subscription is unchecked, removing the email types field
actions.add({"type":"remove","name":"emailTypes"});
}
else
{
emailTypes = {"type":"checkbox","name":"emailTypes","label":"Check the mails that you want to receive","options":{{"label":"Discounts","value":"discounts"},{"label":"Meetings","value":"meetings"},{"label":"Newsletter","value":"news"}},"value":"news"};
actions.add({"type":"add_after","name":"emailSubscription","input":emailTypes});
}
}
}
response = {"type":"form_modification","actions":actions};
return response;