Skip to content

Instantly share code, notes, and snippets.

View anil826's full-sized avatar
🏠
Working from home

Anil anil826

🏠
Working from home
  • New Delhi , India
View GitHub Profile
@anil826
anil826 / Neha_Vyas.js
Created May 13, 2019 07:51
SyngentaNeha
$(document).ready(function() {
var is_sales_orders = false;
var is_marketing_early_pay = false;
var is_marketing_totals = false;
var is_discretionary = false;
var sales_orders = [];
var marketing_early_pay = [];
var marketing_totals = [];
var discretionary = [];
@anil826
anil826 / onbyoneSelection.js
Created May 10, 2019 06:20
trigger two element
//On prefill success trigger other SF select element.
formyoula.form_fields['7221-d2aa-1adf'].on('prefill:success',function(){
$('body').append('<div class="custom-loader"><div class="whirl traditional"><div class="spinner-dialog"><span class="spinner-dialog-title">Loading data</span> <br/><span>Please wait...</span> <br/></div></div></div>');
$('#component-1e42-f81b-0812 button:first').trigger('click');
setTimeout(function(){
//Click on first SF select.
$('#component-1e42-f81b-0812 .select_salesforce_record:first').trigger('click'); //Select first record
$('#component-de81-49c2-670c button:first').trigger('click'); //Click on second SF select
setTimeout(function() {
//Select first record
@anil826
anil826 / dependentPicklistRepeat.js
Last active May 10, 2019 05:21
sygnetaDependent
/***********************First***************************/
var product1 = {
"AUSTRAL PLUS 20 L ROA": ["AUSTRAL PLUS","3250"]
}
//Repeat group event on adding the record
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++ ) {
@anil826
anil826 / status.js
Created May 9, 2019 11:51
Status Update for deferent repeat group.
//on click
$(document).on('click', '.add', 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++ ) {
//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
@anil826
anil826 / SyngentaCheckbox.js
Created May 9, 2019 11:49
Repeat checkbox
// Define a global variable to store the selected item on selection of a checkbox
var selected_values;
// Trigger a function on prefill success once the repeat group is prefilled based on the salesforce selected item
window.formyoula.form_fields["Contact"].on("prefill:success", function(){
// Trigger the below function once the data is populated and the checkbox is selected/unselected
$(document).on('change', 'input[type="checkbox"]', function(e){
// If selected hide the repeat groups other than the selected one
if( $(this).is(':checked') && window.formyoula.form_fields["7221-d2aa-1adf"].changed.repeat_value){
if_checked();
} else {
@anil826
anil826 / onChange.js
Created May 2, 2019 08:36
onChangeSyngenta
//On change on existing repeat group select element please replace the component id of select element
// Inside of repeat group.
$('.existing_repeat_entry_panel #component-751d-c4d1-b504 select').on('change',function(){
$('.existing_repeat_entry_panel #component-751d-c4d1-b504 select').each(function(index,element){
//Get Pre-fill value on select element
var select_value = element ? element.value : '';
//Check the selected pre-fill value if Referencia
console.log('Selected value '+ select_value)
if ( select_value == 'US' ){
@anil826
anil826 / sygentaHidden.js
Last active April 30, 2019 17:01
Sygenta-client_usecase
//Change component-id use SF Lookup componnet id.
$('#component-a5e1-704a-3e72 .lookup_salesforce_record').click(function(){
//Add Interval
var s = setInterval(function(){
//Check for repeat group data
if( window.formyoula.form_fields["5fb5-8b93-521e"].get("repeat_value").length > 0 ) {
var record_ids = []; //Init the temp array variable
//Loop on the repeat_group data
$.each(window.formyoula.form_fields["5fb5-8b93-521e"].get("repeat_value"), function(repeat_element, value) {
//Get the record_id based on componet id from repeat_group.
@anil826
anil826 / getBase64FromImageUrl.js
Last active April 11, 2019 07:45
getBase64FromImageUrl
var imageData = null;
function getBase64FromImageUrl(url) {
var img = new Image();
img.setAttribute('crossOrigin', 'anonymous');
img.src = url;
img.onload = function () {
var canvas = document.createElement("canvas");
canvas.width =this.width;
canvas.height =this.height;
@anil826
anil826 / sample.js
Created February 22, 2019 10:48
SygentaMultiplePDF
/*$(".btn").hide();
formyoula.form_fields["24e6-dc4b-31b9"].on("change", function(){
//loading screen.
//formyoula.event_trigger("main:spinner_dialog", { show: true });
});
*/
$(document).ready(function() {
if(formyoula.form_fields["1a6c-6142-08cc"]){
console.log(formyoula.form_fields["1a6c-6142-08cc"].get("value"));
@anil826
anil826 / example.js
Last active February 26, 2019 13:44
Client side pdf zip with html2pdf and jsZip
//Supported files
//script( type='text/javascript' src="https://fastcdn.org/FileSaver.js/1.1.20151003/FileSaver.min.js").
//script( type='text/javascript' src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.2.0/jszip.min.js").
html2pdf().from(formyoula.get_pdf_html().pdf_html).toPdf().output('datauristring').then(function (pdfAsString) {
// The PDF has been converted to a Data URI string and passed to this function.
// Use pdfAsString however you like (ZIP, send as email, etc)
console.log(pdfAsString);
var zip = new JSZip();
var pdf = zip.folder("PDFS");