Skip to content

Instantly share code, notes, and snippets.

@anil826
Created July 1, 2019 13:57
Show Gist options
  • Save anil826/0ebed589af5937382eb702548080556d to your computer and use it in GitHub Desktop.
Save anil826/0ebed589af5937382eb702548080556d to your computer and use it in GitHub Desktop.
checkAtlistOnProductAvailable (syngenta)
var is_product_available = false;
/*************************************************/
//on click
formyoula.form_fields['c47a-5772-e40f'].on('element:create:success',function() {
//Loop for repeat index
for (var repeat_index=0; repeat_index < window.formyoula.form_fields["c47a-5772-e40f"].get('repeat_value').length; repeat_index++ ) {
is_product_available = true; //True if any product is added
//Looop for component data
for ( var i_component = 0; i_component < window.formyoula.form_fields["c47a-5772-e40f"].get('repeat_value')[repeat_index].length; i_component++ ) {
//Check if type is Salesforce and null value or no value available
if ( window.formyoula.form_fields["c47a-5772-e40f"].get('repeat_value')[repeat_index][i_component].type == "Salesforce" ) {
if ( window.formyoula.form_fields["c47a-5772-e40f"].get('repeat_value')[repeat_index][i_component].value ) {
//Get component_id
var component_id = window.formyoula.form_fields["c47a-5772-e40f"].get('repeat_value')[repeat_index][7].component_id;
//Update UI based on component id.
$("#collapse_c47a-5772-e40f_"+repeat_index+" #component-"+component_id+" .input_content").val('Requested by Grower');
//Set value in repeat group
window.formyoula.form_fields["c47a-5772-e40f"].get('repeat_value')[repeat_index][7].value = 'Requested by Grower'
} else {
console.log('No Exist')
//Get component_id
var component_id = window.formyoula.form_fields["c47a-5772-e40f"].get('repeat_value')[repeat_index][7].component_id;
//Update UI based on component id.
$("#collapse_c47a-5772-e40f_"+repeat_index+" #component-"+component_id+" .input_content").val('Forecasted');
//Set value in repeat group
window.formyoula.form_fields["c47a-5772-e40f"].get('repeat_value')[repeat_index][7].value = 'Forecasted'
}
}
}
}
})
//on click
formyoula.form_fields['879f-f484-fcb7'].on('element:create:success',function() {
//Loop for repeat index
for (var repeat_index=0; repeat_index < window.formyoula.form_fields["879f-f484-fcb7"].get('repeat_value').length; repeat_index++ ) {
is_product_available = true; //True if any product is added
//Looop for component data
for ( var i_component = 0; i_component < window.formyoula.form_fields["879f-f484-fcb7"].get('repeat_value')[repeat_index].length; i_component++ ) {
//Check if type is Salesforce and null value or no value available
if ( window.formyoula.form_fields["879f-f484-fcb7"].get('repeat_value')[repeat_index][i_component].type == "Salesforce" ) {
if ( window.formyoula.form_fields["879f-f484-fcb7"].get('repeat_value')[repeat_index][i_component].value ) {
//Get component_id
var component_id = window.formyoula.form_fields["879f-f484-fcb7"].get('repeat_value')[repeat_index][8].component_id;
//Update UI based on component id.
$("#collapse_879f-f484-fcb7_"+repeat_index+" #component-"+component_id+" .input_content").val('Requested by Grower');
//Set value in repeat group
window.formyoula.form_fields["879f-f484-fcb7"].get('repeat_value')[repeat_index][8].value = 'Requested by Grower'
} else {
console.log('No Exist')
//Get component_id
var component_id = window.formyoula.form_fields["879f-f484-fcb7"].get('repeat_value')[repeat_index][8].component_id;
//Update UI based on component id.
$("#collapse_879f-f484-fcb7_"+repeat_index+" #component-"+component_id+" .input_content").val('Forecasted');
//Set value in repeat group
window.formyoula.form_fields["879f-f484-fcb7"].get('repeat_value')[repeat_index][8].value = 'Forecasted'
}
}
}
}
})
//on click
formyoula.form_fields['ee5e-5329-fcbb'].on('element:create:success',function() {
//Loop for repeat index
for (var repeat_index=0; repeat_index < window.formyoula.form_fields["ee5e-5329-fcbb"].get('repeat_value').length; repeat_index++ ) {
is_product_available = true; //True if any product is added
//Looop for component data
for ( var i_component = 0; i_component < window.formyoula.form_fields["ee5e-5329-fcbb"].get('repeat_value')[repeat_index].length; i_component++ ) {
//Check if type is Salesforce and null value or no value available
if ( window.formyoula.form_fields["ee5e-5329-fcbb"].get('repeat_value')[repeat_index][i_component].type == "Salesforce" ) {
if ( window.formyoula.form_fields["ee5e-5329-fcbb"].get('repeat_value')[repeat_index][i_component].value ) {
//Get component_id
var component_id = window.formyoula.form_fields["ee5e-5329-fcbb"].get('repeat_value')[repeat_index][7].component_id;
//Update UI based on component id.
$("#collapse_ee5e-5329-fcbb_"+repeat_index+" #component-"+component_id+" .input_content").val('Requested by Grower');
//Set value in repeat group
window.formyoula.form_fields["ee5e-5329-fcbb"].get('repeat_value')[repeat_index][7].value = 'Requested by Grower'
} else {
console.log('No Exist')
//Get component_id
var component_id = window.formyoula.form_fields["ee5e-5329-fcbb"].get('repeat_value')[repeat_index][7].component_id;
//Update UI based on component id.
$("#collapse_ee5e-5329-fcbb_"+repeat_index+" #component-"+component_id+" .input_content").val('Forecasted');
//Set value in repeat group
window.formyoula.form_fields["ee5e-5329-fcbb"].get('repeat_value')[repeat_index][7].value = 'Forecasted'
}
}
}
}
})
//Repeat group event on adding the record
formyoula.form_fields['e92d-cd8a-aabe'].on('element:create:success',function() {
//Loop for repeat index
for (var repeat_index=0; repeat_index < window.formyoula.form_fields["e92d-cd8a-aabe"].get('repeat_value').length; repeat_index++ ) {
is_product_available = true; //True if any product is added
//Looop for component data
for ( var i_component = 0; i_component < window.formyoula.form_fields["e92d-cd8a-aabe"].get('repeat_value')[repeat_index].length; i_component++ ) {
//Check if type is Salesforce and null value or no value available
if ( window.formyoula.form_fields["e92d-cd8a-aabe"].get('repeat_value')[repeat_index][i_component].type == "Salesforce" ) {
if ( window.formyoula.form_fields["e92d-cd8a-aabe"].get('repeat_value')[repeat_index][i_component].value ) {
//Get component_id
var component_id = window.formyoula.form_fields["e92d-cd8a-aabe"].get('repeat_value')[repeat_index][9].component_id;
//Update UI based on component id.
$("#collapse_e92d-cd8a-aabe_"+repeat_index+" #component-"+component_id+" .input_content").val('Requested by Grower');
//Set value in repeat group
window.formyoula.form_fields["e92d-cd8a-aabe"].get('repeat_value')[repeat_index][9].value = 'Requested by Grower'
} else {
console.log('No Exist')
//Get component_id
var component_id = window.formyoula.form_fields["e92d-cd8a-aabe"].get('repeat_value')[repeat_index][9].component_id;
//Update UI based on component id.
$("#collapse_e92d-cd8a-aabe_"+repeat_index+" #component-"+component_id+" .input_content").val('Forecasted');
//Set value in repeat group
window.formyoula.form_fields["e92d-cd8a-aabe"].get('repeat_value')[repeat_index][9].value = 'Forecasted'
}
}
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment