Skip to content

Instantly share code, notes, and snippets.

@anil826
Created June 25, 2019 11:24
Show Gist options
  • Save anil826/633bb7a6403cf34bf0872f29f160245e to your computer and use it in GitHub Desktop.
Save anil826/633bb7a6403cf34bf0872f29f160245e to your computer and use it in GitHub Desktop.
PramodPicklist dependency
/***********************Dependency List***************************/
//Dependency JSON
var product1 = {
"Alibaba groß Rapspalette": ["Alibaba groß Rapspalette"]
}
//Repeat group event on adding the record
formyoula.form_fields['f7e2-c61c-8a3a'].on('element:create:success',function() {
//Loop for repeat index
for (var repeat_index=0; repeat_index < window.formyoula.form_fields["f7e2-c61c-8a3a"].get('repeat_value').length; repeat_index++ ) {
//Looop for component data
for ( var i_component = 0; i_component < window.formyoula.form_fields["f7e2-c61c-8a3a"].get('repeat_value')[repeat_index].length; i_component++ ) {
//Check if type is Salesforce and null value or no value available
/****************Code for the picklist****************/
if ( window.formyoula.form_fields["f7e2-c61c-8a3a"].get('repeat_value')[repeat_index][i_component].label == "OLI Price book ID" ) {
//Get selected product
var selected_product = window.formyoula.form_fields["f7e2-c61c-8a3a"].get('repeat_value')[repeat_index][i_component].value;
//Check if dependent picklist available.
if ( product1[selected_product] ) {
window.formyoula.form_fields["f7e2-c61c-8a3a"].get('repeat_value')[repeat_index][3].value = product1[selected_product][0];
//Update UI of the form
$('#collapse_f7e2-c61c-8a3a_'+repeat_index+' #component-49b8-df0d-2c75 .input_content').val(product1[selected_product][0])
}
}
}
}
})
//Event for pre-fill success.
formyoula.form_fields['f7e2-c61c-8a3a'].on('prefill:success',function(){
//Loop for repeat index
for (var repeat_index=0; repeat_index < window.formyoula.form_fields["f7e2-c61c-8a3a"].get('repeat_value').length; repeat_index++ ) {
//Looop for component data
for ( var i_component = 0; i_component < window.formyoula.form_fields["f7e2-c61c-8a3a"].get('repeat_value')[repeat_index].length; i_component++ ) {
//Check if type is Salesforce and null value or no value available
/****************Code for the picklist****************/
if ( window.formyoula.form_fields["f7e2-c61c-8a3a"].get('repeat_value')[repeat_index][i_component].label == "OLI Price book ID" ) {
//Get selected product
var selected_product = window.formyoula.form_fields["f7e2-c61c-8a3a"].get('repeat_value')[repeat_index][i_component].value;
//Check if dependent picklist available.
if ( product1[selected_product] ) {
window.formyoula.form_fields["f7e2-c61c-8a3a"].get('repeat_value')[repeat_index][3].value = product1[selected_product][0];
//Update UI of the form
$('#collapse_f7e2-c61c-8a3a_'+repeat_index+' #component-49b8-df0d-2c75 .input_content').val(product1[selected_product][0])
}
}
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment