function makeFieldRequired(fieldName, message) { makeFieldRequired(fieldName, message, ''); // use if no group name exists for validator set } function makeFieldRequired(fieldName, message, groupName) { // requires fields to be optional in CRM to work properly //console.log('makeFieldRequired: ' + fieldName); var fieldSelector; var fieldLabel; var validatorId; var validatorLabel; var requiredValidator; var value; var duplicateExists; try { fieldSelector = '#' + fieldName; fieldLabel = '#' + fieldName + '_label'; validatorId = fieldName + 'Validator'; validatorLabel = 'RequiredFieldValidator' + fieldName; if ($(fieldSelector) !== undefined) { $(fieldSelector).attr('aria-required', 'true'); $(fieldSelector).prop('title', message); $(fieldSelector).attr('aria-label', message); $(fieldSelector).closest('.control').prev().addClass('required'); $(fieldLabel).next('.validators').append(''); // Create new validator requiredValidator = document.createElement('span'); requiredValidator.style.display = 'none'; requiredValidator.id = validatorId; requiredValidator.controltovalidate = fieldName; requiredValidator.errormessage = '' + message + ''; requiredValidator.display = 'Dynamic'; requiredValidator.validationGroup = groupName; requiredValidator.initialvalue = ''; requiredValidator.evaluationfunction = function () { value = $(fieldSelector).val(); console.log(fieldSelector + value); const isRadioButton = $(fieldSelector).find("input[type='radio']"); if (isRadioButton.length > 0) { //radio button input validator const radioButtonValueChecked = $(fieldSelector).find("input[type='radio']:checked"); if (radioButtonValueChecked.length > 0) { value = radioButtonValueChecked.val(); isValid = value !== null && value !== undefined && value.trim() !== ""; } else { // Fallback for other inputs value = $(fieldSelector).val(); isValid = value !== null && value !== undefined && value.trim() !== ""; } if (isValid) { $("#" + validatorId).hide(); } else { $("#" + validatorId).show(); } return isValid; } else { //Anything other than radio button inputs validator if (value !== null && value !== '' && value !== undefined && value.match(/^ *$/) === null) { return true; } else { return false; } } }; requiredValidator.dispose = function () { Array.remove(Page_Validators, $(validatorLabel)); } // Add the new validator to the page validators array: duplicateExists = false; for (i = 0; i < Page_Validators.length; i++) { if (Page_Validators[i].id == validatorId) { duplicateExists = true; break; } } if (!duplicateExists) { Page_Validators.push(requiredValidator); $('a[href="' + fieldLabel + '"]').on('click', function () { scrollToAndFocus(fieldLabel, fieldName); }); } } } catch (error) { console.log('An error occurred trying to add validator for [' + fieldName + ']'); } } function makeFieldOptional(fieldName) { // requires fields to be optional in CRM to work properly //console.log('makeFieldOptional: ' + fieldName); var validatorId; try { validatorId = fieldName + 'Validator'; if ($("#" + fieldName) !== undefined) { $("#" + fieldName).closest(".control").prev().removeClass("required"); $("#" + fieldName).prop('required', false); for (i = 0; i < Page_Validators.length; i++) { if (Page_Validators[i].id == validatorId) { Page_Validators.splice(i,1); break; } } } } catch (error) { console.log('An error occurred trying to remove validator for [' + fieldName + ']'); } } function addRegexValidator(fieldName,errmessage,regularexpression){ var fieldSelector; var fieldLabel; var validatorId; var validatorLabel; try { fieldSelector = '#' + fieldName; fieldLabel = '#' + fieldName + '_label'; validatorId = fieldName + 'RegexValidator'; validatorLabel = 'RegularExpressionValidator' + fieldName; if ($(fieldSelector) !== undefined) { $(fieldLabel).next('.validators').append(''); // Create new validator regexValidator = document.createElement('span'); regexValidator.style.display = 'none'; regexValidator.id = validatorId; regexValidator.controltovalidate = fieldName; regexValidator.errormessage = '' + errmessage + ''; regexValidator.display = 'Dynamic'; regexValidator.evaluationfunction = RegularExpressionValidatorEvaluateIsValid; regexValidator.validationexpression = regularexpression; regexValidator.dispose = function () { Array.remove(Page_Validators, $(validatorLabel)); } // Add the new validator to the page validators array: duplicateExists = false; for (i = 0; i < Page_Validators.length; i++) { if (Page_Validators[i].id == validatorId) { duplicateExists = true; break; } } if (!duplicateExists) { Page_Validators.push(regexValidator); $('a[href="' + fieldLabel + '"]').on('click', function () { scrollToAndFocus(fieldLabel, fieldName); }); } } } catch (error) { console.log('An error occurred trying to add Regex validator for [' + fieldName + ']'); } } function removeRegexValidator(fieldName) { var validatorId; try { validatorId = fieldName + 'RegexValidator'; if ($("#" + fieldName) !== undefined) { for (i = 0; i < Page_Validators.length; i++) { if (Page_Validators[i].id == validatorId) { Page_Validators.splice(i); break; } } } } catch (error) { console.log('An error occurred trying to remove Regex validator for [' + fieldName + ']'); } } function removePageValidations() { var validatorsToKeep = ["MaximumLengthValidator", "DateFormatValidator", "RangeValidator", "EmailFormatValidator", "RegularExpressionValidator", "AttachFileAcceptValidator", "AttachFileSizeValidator"]; var executeRemoval; var deletedItemsArray = []; var pv_length = Page_Validators.length; console.log("Removing page validators"); for (i = 0; i < pv_length; i++) { if (Page_Validators[i] !== undefined) { executeRemoval = true; var temp = Page_Validators[i].id; for (var a in validatorsToKeep) { if (temp.includes(validatorsToKeep[a])) { executeRemoval = false; break; } } if (executeRemoval == true) { $('#' + Page_Validators[i].controltovalidate).parent().parent().find("div.info").removeClass("required"); var itemRemoved = Page_Validators.splice(i, 1); deletedItemsArray.push(itemRemoved[0]); i = i - 1; pv_length = pv_length - 1; } } else { //console.log("undefined" + " " + i); } } //console.log("Updated page validatiors", Page_Validators); //console.log("Validators removed", arrDeletedItems); return deletedItemsArray; } function addPageValidations(itemsArray){ console.log("Adding Page Validations"); for (i = 0; i < itemsArray.length; i++) { $('#' + itemsArray[i].controltovalidate).parent().parent().find("div.info").addClass("required"); Page_Validators.push(itemsArray[i]); } } function isValidationSummaryDisplayed() { var style = $("div[id*='ValidationSummary']").attr('style'); if (style.includes('display') && style.includes('none')) { return false; } else { return true; } } function subgridOnLoad(subgridId, runFunction){ $(subgridId).find(".entity-grid.subgrid").on("loaded", function () { console.time("subgridOnLoad " + subgridId); runFunction(); console.timeEnd("subgridOnLoad " + subgridId); }); } function addSubgridEditLink(subgridId){ var columnName = $(subgridId + ' thead tr th a').first().attr('aria-label'); var columnRow = subgridId + ' tbody tr td[data-th="'+columnName+'"]'; $(columnRow).addClass('subgridRecordLink').on('click', function(event) { $(this).parent().find('li a[title="Edit"]').triggerHandler('click'); }); } function addSubgridViewLink(subgridId){ var columnName = $(subgridId + ' thead tr th a').first().attr('aria-label'); var columnRow = subgridId + ' tbody tr td[data-th="'+columnName+'"]'; $(columnRow).addClass('subgridRecordLink').on('click', function(event) { $(this).parent().find('li a[title="View"]').triggerHandler('click'); }); } function updateSubgridActionsText(){ var subgridActions = 'div.subgrid div.entity-grid.subgrid th[aria-label="Actions"]'; if ($(subgridActions).length > 0) { $(subgridActions).text("Actions"); //Fixes the actions text not showing } } function sortDropdownList(DropdownName) { var selectOptions = $("#"+DropdownName+" option"); var selectedOption = $("#"+DropdownName).val(); console.log("sortDropdownList : selectedOption while Entering : " + selectedOption); selectOptions.sort(function(a, b) { if (a.text > b.text) { return 1; } else if (a.text < b.text) { return -1; } else { return 0; } }); $("#"+DropdownName).empty().append(selectOptions); selectedOption ? $("#"+DropdownName).val(selectedOption) : $("#"+DropdownName).val(""); console.log("sortDropdownList : selectedOption while Exiting : " + $("#"+DropdownName).val()); } function clearFieldValue(fieldId) { $("#"+fieldId).val(""); $("#"+fieldId).prop("value", ""); $("#"+fieldId).attr("value", ""); } function populateFieldValue(fieldId, value) { $("#"+fieldId).val(value); $("#"+fieldId).prop("value", value); $("#"+fieldId).attr("value", value); } function makeFieldNonEditable(fieldId) { $("#"+fieldId).prop("readonly", "readonly"); } function makeFieldEditable(fieldId) { $("#"+fieldId).prop("readonly", ""); $("#"+fieldId).prop("disabled", ""); } /////////////////////// //NJOAG NEW FUNCTIONS: function CreateAlertLabel(elementToCreate, id, innerHtml, className, style, insertBeforeElementJQuery, closestElement) { var alertLabel = document.createElement(elementToCreate); //div alertLabel.id = id; alertLabel.innerHTML = innerHtml; alertLabel.className = className; alertLabel.style = style; $(alertLabel).insertBefore($(insertBeforeElementJQuery).closest(closestElement));//table } function ChangeSectionFieldsRequirement(fieldset, isRequired) { $('fieldset[aria-label="'+fieldset+'"] input:not([type="checkbox"]),fieldset[aria-label="'+fieldset+'"] select').each(function(i, x){ if (isRequired) { var fieldName = $(x).closest("div.control").siblings(".table-info").children(".field-label")[0].textContent; var message = fieldName + " is required. Please provide a value." makeFieldRequired(x.id, message, ""); } else { makeFieldOptional(x.id); } }); } function makeFieldDisabled(fieldId) { $(fieldId).prop("disabled", true); $(fieldId).prop("readonly", "readonly"); } function makeFieldNonEditable(fieldId) { $(fieldId).prop("readonly", "readonly"); } function makeFieldEditable(fieldId) { $("#"+fieldId).prop("readonly", ""); $("#"+fieldId).prop("disabled", ""); } function makeFieldsNonEditableInFieldset(sectionName) { $("fieldset[aria-label='"+ sectionName +"'] input, fieldset[aria-label='"+ sectionName +"'] select").each(function(i,x){ makeFieldDisabled(x); }); } function makeFieldsNonEditableInSection(sectionName) { $("div [data-name='"+ sectionName +"'] input, div [data-name='"+ sectionName +"'] select").each(function(i,x){ makeFieldNonEditable(x); }); } function CloneField(fieldName) { var clonedField = $("#"+fieldName).closest("tr").clone(); $("#"+fieldName).closest("tr").hide(); clonedField.find("[id='"+fieldName+"']").attr("id", "temp_"+fieldName); clonedField.find("[id='"+fieldName+"']").attr("value",$("#"+fieldName).attr("value")); $("#"+fieldName).parent().find(".text-muted").remove(); $(clonedField).insertBefore($("#"+fieldName).closest("tr")); //todo:need to update the actual field on save/insert of this step } //Mask the field to currency format function AddFieldMask_Money(jQuery) { $(jQuery).maskMoney({ //prefix: '$', // Adds the dollar sign allowNegative: false, // Prevents negative values allowZero: true, thousands: ',', // Adds comma as thousand separator decimal: '.', // Uses dot as decimal separator affixesStay: true, // Keeps the prefix and suffix precision: 0 }); $(jQuery).maskMoney('mask'); } function AddFieldMask_DollarSignBlock(jQueryElement) { $(jQueryElement).closest("div").addClass("input-group"); //mb-3 var dollarSignBlock = document.createElement('span'); dollarSignBlock.className = "input-group-text"; dollarSignBlock.innerHTML = "$"; $(dollarSignBlock).insertBefore($(jQueryElement)); //jQuery ex. ".money input" } function AddFieldMask_PercentSignBlock(jQueryElement) { $(jQueryElement).closest("div").addClass("input-group"); //mb-3 var percentSignBlock = document.createElement('span'); percentSignBlock.className = "input-group-text"; percentSignBlock.innerHTML = "%"; $(percentSignBlock).insertBefore($(jQueryElement)); //jQuery ex. ".money input" } function AddFieldMask_DollarSign(fieldName) { $("#"+fieldName).on('change', function() { let value = $(this).val(); if (value.charAt(0) !== '$') { $(this).val('$' + value); } $(this).parent().find(".text-muted").remove(); //remove "-" symbol put by default }); } function updateURLParameter(url, param, paramValue) { let newURL = new URL(url); let params = new URLSearchParams(newURL.search); // Update or add the parameter params.set(param, paramValue); // Return the updated URL newURL.search = params.toString(); return newURL.toString(); } $.urlParam = function(name) { var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href); return results !== null; }; // Usage if ($.urlParam('yourParameter')) { console.log('Parameter exists!'); } else { console.log('Parameter does not exist.'); } function fixSidebarLinks() { $("div.sidebar-section-items a").each(function(i, x){ $(x).click(function(){ window.location.assign(x.href); }); }); } /*---------------------BEGIN DocuSign Functions--------------------------*/ // returns array of financial officer(s) info from current context function getOfficerInfo(signee1, signee2){ var officerList = [ { name: $(`${signee1}_name`).val(), email: "", guid: $(signee1).val(), officer: 1 }, { name: $(`${signee2}_name`).val(), email: "", guid: $(signee2).val(), officer: 2 }] //get officer data from dataverse officerList.forEach((officer) => { $.ajax({ method: "GET", async: false, url: `/Docusign_Officer_Fetch/?id=${officer.guid}` }) .done(function(msg) { officer.name = msg.fullName; officer.email = msg.email; officer.guid = msg.contactid; }); }) return officerList } //triggers flow to send email to current fiscal officers function sendSignatures(entity){ $("#sendButton").attr('disabled', true); //$("#refreshButton").attr('disabled', false); //$("#refreshButton").css(cssRefreshButtonDisplay); $("#signatureStatus1").css(cssSignaturePendingStatus); $("#signatureStatus2").css(cssSignaturePendingStatus); $("#signatureStatus1").text("Pending"); $("#signatureStatus2").text("Pending"); $("#signatureStatus1").css(cssSignatureDisplay1); $("#signatureStatus2").css(cssSignatureDisplay2); var flowURL = "/_api/cloudflow/v1.0/trigger/" switch(entity){ case"account": flowURL += "69539597-36ac-ef11-b8e9-001dd804e07a"; break; case"crsm_pfrregistration": flowURL += "68e45612-e5b7-ef11-b8e9-001dd804c7ab"; break; case "crsm_solicitorregistration": flowURL += "177a8fbd-7ec7-ef11-b8e9-001dd804e07a"; break; case "crsm_noticeofintent": flowURL += "56b23191-dbbe-ef11-b8e9-001dd804eb05"; break; case "crsm_pfrcontractreport": flowURL += "6b3009d0-91c7-ef11-b8e9-001dd8051141"; break; case "crsm_commercialcoventurereport": flowURL += "e6746e14-50c1-ef11-b8e9-001dd804e07a"; break; } var data = { Record_Guid: $('#EntityFormView_EntityID').val() }; var payload = {}; payload.eventData = JSON.stringify(data); shell .ajaxSafePost({ type: "POST", contentType:"application/json", url: flowURL, data: JSON.stringify(payload), processData : false, global : false }).done(function (response) { console.log("success!"); const result = JSON.parse(response); //display modal popup verifying that email has been sent? $("#refreshButton").show(); $("#refreshButton").attr('disabled', false); $("#crsm_docusignenvelopeid").val(result.envelopeid); //docusignSignatureStatus = '140000001' $('#newEnvelope').show(); $("#newEnvelope").attr('disabled', false); $("#newSolicitorRegistration").show(); $("#newSolicitorRegistration").attr('disabled', false); }) .fail(function () { //alert("failed"); }); } //triggers flow to validate signature status of current fiscal officers, and updates if one or more has signed function refreshSignatureStatus(isAsync, entityType) { $("#refreshButton").attr('disabled', true); $("#paymentButton").attr('disabled', true); $("#paymentButton").hide(); if(isAsync){ $(".spinner-border").show(); } if($('#crsm_docusignenvelopeid').val()){ if(isAsync){ $(".spinner-border").show(); } var data = { Envelope_ID: $('#crsm_docusignenvelopeid').val(), Entity_Type: entityType }; if(data.Envelope_ID !== null){ //checks if envelopeID is populated, if not, refresh page to get updated value after send flow is completed var payload = {}; payload.eventData = JSON.stringify(data); shell .ajaxSafePost({ type: "POST", contentType:"application/json", url: "/_api/cloudflow/v1.0/trigger/e5f82201-57b2-ef11-b8e9-001dd804c7ab", data: JSON.stringify(payload), processData : false, async : false, global : false }).done(function (response) { const result = JSON.parse(response); var statusesTags = [$("#signatureStatus1"),$("#signatureStatus2")]; //setting Officer field names & certification sections to use dynamically below let signee1, signee2, certificationSection; switch(result.entity_type){ case "account": signee1 = "#crsm_officer1"; signee2 = "#crsm_officer2"; break; case "crsm_pfrregistration": signee1 = ""; signee2 = ""; break; case "crsm_pfrcontractreport": signee1 = "#crsm_authorizedofficerpfr"; signee2 = "#crsm_authorizedofficercharity"; //certificationSection = 'fieldset[aria-label="Certification Signatures"]'; break; case "crsm_solicitorregistration": signee1 = "#crsm_solicitor"; signee2 = "#crsm_authorizedofficer"; //certificationSection = "#"; break; case "crsm_noticeofintent": signee1 = "#crsm_authorizedofficer1"; signee2 = "#crsm_authorizedofficer2"; //certificationSection = "fieldset[aria-label='Certifying Officers']"; break; case "crsm_commercialcoventurereport": signee1 = "#crsm_chieffinancialofficercharity"; signee2 = "#crsm_coventurefiscalofficer"; //certificationSection = 'fieldset[aria-label="Certification Signatures"]'; break; } const officerList = getOfficerInfo(signee1, signee2); if(result.response_status == 200){ const resultArr = [JSON.parse(result.signature_status1json),JSON.parse(result.signature_status2json)] //These two responses are not necessarily concurrent with Officer1 & Officer2 schema, therefore we need to match them to the email var i = 0 statusesTags.forEach(tag => { resultArr.forEach(result => { if(result.email.toLowerCase() === officerList[i].email.toLowerCase()){ switch(result.status.toLowerCase()){ case "sent": case "delivered": tag.css(cssSignaturePendingStatus) tag.text('Pending') $("#paymentButton").hide(); $("#paymentButton").attr('disabled', true); $('#newEnvelope').show(); $("#newEnvelope").attr('disabled', false); $("#sendButton").attr('disabled', true); $("#refreshButton").show(); $("#refreshButton").attr('disabled', false); if(result.entity_type == "crsm_solicitorregistration"){ $("#newSolicitorRegistration").show(); $("#newSolicitorRegistration").attr('disabled', false); } break; case "autoresponded": $('#newEnvelope').show(); $("#newEnvelope").attr('disabled', false); // autoresponded Alert var autorespondedAlert = $(` `); $('fieldset[aria-label="Certification Signatures"]').last().after(autorespondedAlert); $("#autoresponded-alert").show(500); break; case "completed": tag.css(cssSignatureConfirmedStatus); tag.text('Completed'); break; default: break; } } }); i++; }); //Completed if(statusesTags[0].text() === "Completed" && statusesTags[1].text() === "Completed"){ statusesTags.forEach(tag => { tag.css(cssSignatureConfirmedStatus); tag.text("Completed"); }); $('#newEnvelope').show(); $("#newEnvelope").attr('disabled', true); $("#paymentButton").show(); $("#paymentButton").attr('disabled', isShoppingCartPaid); $("#sendButton").show(); $("#sendButton").attr('disabled', true); $("#refreshButton").show(); $("#refreshButton").attr('disabled', true); if(result.entity_type == "crsm_solicitorregistration"){ $("#newSolicitorRegistration").hide(); $("#newSolicitorRegistration").attr('disabled', true); } } } else{ //Not Sent statusesTags.forEach(tag => { tag.css(cssSignatureRequiredStatus) tag.text('Required') }); $('#newEnvelope').hide(); $("#newEnvelope").attr('disabled', true); $("#paymentButton").hide(); $("#paymentButton").attr('disabled', true); $("#sendButton").show(); $("#sendButton").attr('disabled', false); $("#refreshButton").css({'display':'none'}); if(result.entity_type == "crsm_solicitorregistration"){ $("#newSolicitorRegistration").hide(); $("#newSolicitorRegistration").attr('disabled', true); } } $(".spinner-border").hide(); }).fail(function () { var statusesTags = [$("#signatureStatus1"),$("#signatureStatus2")]; statusesTags.forEach(tag => { tag.css({'display':'none'}); tag.text('Something went wrong') }); $(".spinner-border").hide(); //temp //$('#NextButton').show(); $('#NextButton').attr('disabled', false); $("#refreshButton").attr('disabled', false); }); } } else{ $(".spinner-border").hide(); console.log('No Envelope found'); } } function voidAndCreateNewEnvelope(envelopeId){ $(".spinner-border").show(); var data = { Envelope_ID: envelopeId }; var payload = {}; payload.eventData = JSON.stringify(data); shell .ajaxSafePost({ type: "POST", contentType:"application/json", url: "/_api/cloudflow/v1.0/trigger/bdcf1d54-acef-ef11-be20-001dd8306aec", data: JSON.stringify(payload), processData : false, global : false }).done(function (response) { console.log("success!"); var statusesTags = [$("#signatureStatus1"),$("#signatureStatus2")]; statusesTags.forEach(tag => { tag.css(cssSignatureRequiredStatus); tag.text('Required'); }); $("#paymentButton").hide(); $("#paymentButton").attr('disabled', true); $("#newEnvelope").hide(); $("#newEnvelope").attr('disabled', true); $("#refreshButton").hide(); $("#refreshButton").attr('disabled', true); $("#sendButton").show(); $("#sendButton").attr('disabled', false); $("#crsm_docusignenvelopeid").val(""); $("#newSolicitorRegistration").hide(); $("#newSolicitorRegistration").attr('disabled', true); //$("#select1").show(); //$("#select1").attr("disabled",false); //$("#select2").show(); //$("#select2").attr("disabled",false); $(".spinner-border").hide(); }) .fail(function () { $(".spinner-border").hide(); //alert("failed"); }); } /*----------------------END DocuSign Functions---------------------------*/ /*---------------------BEGIN NICUSA Functions--------------------------*/ function createShoppingCart(sessionId, feeType, OrgId, isCharity, recordId, lineItemName, visitorId ,shoppingCartId){ var data = { Session_ID: sessionId, Fee_Type: feeType, Shopping_Cart_ID: shoppingCartId, Regarding_Organization_ID: OrgId, isCharity: isCharity, Record_Guid_to_Associate: recordId, lineItem_FeeName: lineItemName, Visitor_ID: visitorId }; var payload = {}; payload.eventData = JSON.stringify(data); shell .ajaxSafePost({ type: "POST", contentType:"application/json", url: "/_api/cloudflow/v1.0/trigger/24744f2b-fa92-ef11-ac21-001dd804eb05", data: JSON.stringify(payload), processData : false, global : false }).done(function (response) { const result = JSON.parse(response); //console.log("flow =" + result); shoppingCartID = result.crsm_shoppingcartid; }) .fail(function () { //alert("failed"); }); } function sendToNICUSA(shoppingCartID ,registrationType, sessionId) { //console.log(`NICUSA Shopping CartId: ${shoppingCartID}`); $(".spinner-border").show(); $("#paymentButton").attr('Disabled',true); var data = { Shopping_Cart_ID: shoppingCartID, Registration_Type: registrationType, Session_ID: sessionId, Partial_URL: window.location.pathname }; var payload = {}; payload.eventData = JSON.stringify(data); shell .ajaxSafePost({ type: "POST", contentType:"application/json", url: "/_api/cloudflow/v1.0/trigger/b94ede34-7ade-ef11-8eea-001dd804eb05", data: JSON.stringify(payload), processData : false, global : false }).done(function (response) { $(".spinner-border").hide(); const result = JSON.parse(response); debugger; if(result.status == 308){ console.log("flow =" + result.paymenturl); window.open(result.paymenturl,"_self"); } else{ // autoresponded Alert var paymentErrorAlert = $(` `); $("#BillFees").last().after(paymentErrorAlert); $("#autoresponded-alert").show(500); } }) .fail(function () { $(".spinner-border").hide(); //alert("failed"); }); } function createPayment(shoppingCartId, liqTransStat) { let tranStatVar = liqTransStat if (tranStatVar === ""){tranStatVar = "4"} var data = { Shopping_Cart_ID: shoppingCartId, transtat: tranStatVar }; var payload = {}; payload.eventData = JSON.stringify(data); shell .ajaxSafePost({ type: "POST", contentType:"application/json", url: "/_api/cloudflow/v1.0/trigger/38ec1d00-50ed-ef11-be20-001dd8051f20", data: JSON.stringify(payload), async : false, processData : false, global : false }).done(function (response) { const result = JSON.parse(response); console.log("payment record success. Redirect in process"); if(result.status === 308){ $('#paymentButton').attr('disabled',true) let signaturePaymentAlert = $(` `); signaturePaymentAlert.insertBefore($("#BillFees"));//$("#BillFees").last().after(signaturePaymentAlert); $('#BillFees').hide(); } else { return result.status; } }) .fail(function () { //alert("failed"); }); } function formatCurrency(amount) { return new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(amount); } function populatePaymentDue(shoppingCartId, totalAmountDue, shoppingCartItems) { console.log("items = " + shoppingCartItems) shoppingCartItems.forEach(function(shoppingCartItem) { let number = shoppingCartItem[2]; let formattedNumber = formatCurrency(number); console.log(formattedNumber); // Output: $1,234.57 var newItemRow = ""; if(shoppingCartItem[1] == 'Organization Balance'){shoppingCartItem[1] = number < 0 ? 'Credit Balance' : 'Balance Due';} newItemRow += "" + shoppingCartItem[1] + ""; newItemRow += "" + formattedNumber + ""; newItemRow += "
"; newItemRow += ""; $("#BillFees tbody").append(newItemRow); }); console.log(`SC ID: ${shoppingCartId}`); formattedTotalNumber = formatCurrency(totalAmountDue); var totalAmountDueRow = "Total: " + formattedTotalNumber + "" $("#BillFees tbody").append(totalAmountDueRow); } /*----------------------END NICUSA Functions---------------------------*/