// Questions Component Namespace ; SRQUESTIONSCOMPNS = { getDepedentFields: function() { console.log('Inside Dependent Field Function'); if(licGlobalObj.currentRecId != null) { var fieldsQuery = 'SELECT Id'; $.each(questionsList, function(i, val) { if((val.parentFieldObject == currObjName) && (val.parentField != null)) { fieldsQuery = fieldsQuery + ', ' + val.parentField; } $.each(val.childQueList, function(j, val2) { if( (val2.parentFieldObject == currObjName) && (val2.parentField != null)) { fieldsQuery = fieldsQuery + ', ' + val2.parentField; } }); }); fieldsQuery = fieldsQuery + " FROM " + currObjName + " WHERE Id = '" + licGlobalObj.currentRecId + "'"; var resultDependentFields = sforce.connection.query(fieldsQuery); recordsDependentFields = resultDependentFields.getArray("records"); $.each(questionsList, function(i, val) { if(val.parentFieldObject == currObjName) { if(val.parentField != null) { if(val.qualifyingResponseForField == eval('recordsDependentFields[0].' + val.parentField)) { val.show = true; } else { val.show = false; } } else { val.show = true; } } else if(val.parentFieldObject != null) { val.show = false; } else { val.show = true; } $.each(val.childQueList, function(j, val2) { if(val2.parentFieldObject == currObjName) { if(val2.parentField != null) { if(val2.qualifyingResponseForField == eval('recordsDependentFields[0].' + val2.parentField)) { val2.show = true; } else { val2.show = false; } } else { val2.show = true; } } else if(val2.parentFieldObject != null) { val2.show = false; } else { val2.show = true; } }); //Loop through Child Group Questions added by shiva if(val.Map_Of_AnswerGroup_childQuestionsGroup_JSON != null) { //looping through the map keys - which are nothing but Answer Group Values Object.keys(val.Map_Of_AnswerGroup_childQuestionsGroup).map(function(key, index) { // looping through values for each Key - i.e, for each Answer Group Value $.each(val.Map_Of_AnswerGroup_childQuestionsGroup[key], function(k, val3) { if(val3.parentFieldObject == currObjName) { if(val3.parentField != null) { //determining whether to show the question or not based on parent field value if(val3.qualifyingResponseForField == eval('recordsDependentFields[0].' + val3.parentField)) { val3.show = true; } else { val3.show = false; } } else { val3.show = true; } } else if(val3.parentFieldObject != null) { val3.show = false; } else { val3.show = true; } }); }); }//added by shiva }); } console.log('Exit Dependent Field Function'); }, /* Get data, build marup and inject */ loadRecords: function() { console.log('Inside Load Records Function'); // Initialize variables var innerHtml = ''; var innerHtml2 = ''; var innerHtml3 = ''; var innerHtml4 = ''; // Empty list $(".injectQuestions").empty(); try { // Loop through parent questions // console.log(questionsList); var date = document.querySelector('input[type="date"]'); console.log('date vals'+date); $.each(questionsList, function(i, val) { if(val.show) { // Remove null values if(val.answerText == null) { val.answerText = ''; } if(val.answerComment == null) { val.answerComment = ''; } // If Yes-No type of question if(val.dataType == 'Yes_No') { // Build parent question markup innerHtml += '
' + val.questionBody + '
'; } // If picklist else if(val.dataType == 'Picklist') { // Build parent question markup innerHtml += '
'; } else if(val.dataType == 'Multi-Select Picklist'){ innerHtml += '
'; } // If text else if(val.dataType == 'Text') { if(val.numberrelated) { innerHtml += '
'; } else if(val.daterelated){ innerHtml += '
'; } else{ // Build parent question markup innerHtml += '
'; } } // Inject parent markup $(".injectQuestions").append(innerHtml); $('.datePick').datepicker({ dateFormat: 'mm-dd-yy' }); // Add picklist values var picklistHtml = ''; $.each(val.possibleResponses, function(k, val3) { picklistHtml += ''; }); $("#parentPkListAns" + val.id).append(picklistHtml); // Loop through child questions $.each(val.childQueList, function(j, val2) { if(val2.show) { // Remove null values if(val2.answerText == null) { val2.answerText = ''; } if(val2.answerComment == null) { val2.answerComment = ''; } // If Yes-No type of question if(val2.dataType == 'Yes_No') { // Build parent question markup innerHtml2 += ''; } else if(val2.dataType == 'Picklist') { // Build parent question markup innerHtml2 += ''; } else if(val2.dataType == 'Multi-Select Picklist'){ innerHtml2 += ''; } else if(val2.dataType == 'Text') { // Build parent question markup if(val2.numberrelated) { innerHtml2 += '
'; } else if(val2.daterelated){ innerHtml2 += '
'; } else{ innerHtml2 += '