Page tree
Skip to end of metadata
Go to start of metadata

Playground and DEMO space

This is a playground and demo space for ConfiForms and ConfiDoc addons developed and supported by Vertuna LLC

Most pages provide a storage format for the demo, so you can use the free add-on from Atlassian Confluence Source Editor to import this configuration into your Confluence and see it in action

Please note, all the examples here are provided without any obligation and may or may not be incomplete or may have bugs, and we provide NO SUPPORT for these examples and demos.


Calculates percentage using ConfiForms REST API by aggregating rows from TotalAmount and Deductible fields



Data

Team

Year

Month

Total Amount

Deductible

Percent Deductible

Team 1 2021 January 1000 30 3%
Team 1 2021 January 310 10 3%
Team 1 2021 February 4524 3891 86%
Export Records: 3

Total % 


The code to calculate the average is

<p>Total % <span id="confiReport"></span></p>

<script type="application/javascript">
  function totalPercent(ta, td) {
   return Math.round((td / ta) * 100);
  }

  AJS.toInit(function() {
	var isPageEdit = AJS.$('#content').hasClass('page edit');	

    if (!isPageEdit) {
      var url = 'https://wiki.vertuna.com/ajax/confiforms/rest/filter.action?pageId=52626406&f=AmountTracking1&q=';
	  var xhr = AJS.$.ajax({
  		url: url,
  		timeout: 10000, // 10 sec
  		success: function (data) {
            var ta = 0;
            var td = 0;
            var rows = data.list.entry;
			for (i=0;i<rows.length;i++) {
				ta = ta + rows[i].fields.TotalAmount;
                td = td + rows[i].fields.Deductible;
            }
            AJS.$('#confiReport').append(totalPercent(ta, td));
    		
  		},
  		error: function (jqXHR, textStatus, errorThrown) {
    		console.log('request to get data from ConfiForms has failed... ' + textStatus);
  		}
	});
   }

  });
</script>

Form configuration 

<ac:structured-macro ac:macro-id="660462e3-4177-454c-beef-6d0ae17c187e" ac:name="confiform" ac:schema-version="1">
  <ac:parameter ac:name="formName">AmountTracking1</ac:parameter>
  <ac:parameter ac:name="allowReads">true</ac:parameter>
  <ac:parameter ac:name="export">true</ac:parameter>
  <ac:parameter ac:name="registrationFormTitle">Amount Tracking</ac:parameter>
  <ac:rich-text-body>
    <p>
      <br/>
    </p>
    <p>
      <ac:structured-macro ac:macro-id="2ec1405c-016e-48c3-bb51-3eed86c8e968" ac:name="confiform-field-definition" ac:schema-version="1">
        <ac:parameter ac:name="fieldName">Team</ac:parameter>
        <ac:parameter ac:name="fieldLabel">Team</ac:parameter>
        <ac:parameter ac:name="values">false[1=Team 1|2=Team 2|]</ac:parameter>
        <ac:parameter ac:name="extras">label;false</ac:parameter>
        <ac:parameter ac:name="type">select</ac:parameter>
        <ac:parameter ac:name="required">true</ac:parameter>
      </ac:structured-macro>
    </p>
    <p>
      <ac:structured-macro ac:macro-id="03d391c2-ebc5-43ea-89ca-130c156e8b22" ac:name="confiform-field-definition" ac:schema-version="1">
        <ac:parameter ac:name="fieldName">Year</ac:parameter>
        <ac:parameter ac:name="fieldLabel">Year</ac:parameter>
        <ac:parameter ac:name="values">false[1=2021|2=2022|]</ac:parameter>
        <ac:parameter ac:name="type">select</ac:parameter>
        <ac:parameter ac:name="required">true</ac:parameter>
      </ac:structured-macro>
    </p>
    <p>
      <ac:structured-macro ac:macro-id="21a2a149-332d-4598-82e2-b382bdd80f17" ac:name="confiform-field-definition" ac:schema-version="1">
        <ac:parameter ac:name="fieldName">Month</ac:parameter>
        <ac:parameter ac:name="fieldLabel">Month</ac:parameter>
        <ac:parameter ac:name="values">false[1=January|2=February|]</ac:parameter>
        <ac:parameter ac:name="extras">label;true</ac:parameter>
        <ac:parameter ac:name="type">select</ac:parameter>
        <ac:parameter ac:name="required">true</ac:parameter>
      </ac:structured-macro>
    </p>
    <p>
      <ac:structured-macro ac:macro-id="741e5ede-7e42-4ae6-b10b-0b7e0771ee8a" ac:name="confiform-field-definition" ac:schema-version="1">
        <ac:parameter ac:name="fieldName">TotalAmount</ac:parameter>
        <ac:parameter ac:name="fieldLabel">Total Amount</ac:parameter>
        <ac:parameter ac:name="values">false[1=Payments Insider|2=Elavon Connect|3=ServiceCloud - Salesforce|]</ac:parameter>
        <ac:parameter ac:name="extras">label;true</ac:parameter>
        <ac:parameter ac:name="type">number</ac:parameter>
        <ac:parameter ac:name="required">true</ac:parameter>
      </ac:structured-macro>
    </p>
    <p>
      <ac:structured-macro ac:macro-id="f58f31ec-e9bb-4cd6-aa84-6ad67f22419d" ac:name="confiform-field-definition" ac:schema-version="1">
        <ac:parameter ac:name="fieldName">Deductible</ac:parameter>
        <ac:parameter ac:name="fieldLabel">Deductible</ac:parameter>
        <ac:parameter ac:name="values">false[1=Payments Insider|2=Elavon Connect|3=ServiceCloud - Salesforce|]</ac:parameter>
        <ac:parameter ac:name="extras">label;true</ac:parameter>
        <ac:parameter ac:name="type">number</ac:parameter>
        <ac:parameter ac:name="required">true</ac:parameter>
      </ac:structured-macro>
    </p>
    <p>
      <ac:structured-macro ac:macro-id="ea4c385f-3e50-45cd-9469-818a2fc2b878" ac:name="confiform-field-definition" ac:schema-version="1">
        <ac:parameter ac:name="fieldName">PercentDeductible</ac:parameter>
        <ac:parameter ac:name="fieldLabel">Percent Deductible</ac:parameter>
        <ac:parameter ac:name="extras">CONCAT(ROUND((([entry.Deductible] / [entry.TotalAmount]) * 100),0),"%")</ac:parameter>
        <ac:parameter ac:name="fieldDescription">Dividing # Automated TC by Total # of TCs</ac:parameter>
        <ac:parameter ac:name="type">formula</ac:parameter>
      </ac:structured-macro>
    </p>
    <p>
      <br/>
    </p>
  </ac:rich-text-body>
</ac:structured-macro>
  • No labels