Bachelor Tech
  • Home
  • Tutorials
  • Portfolio
  • About Jan
  • Contact Jan

Part 3 – Design the parent form for individual expenses (Gravity Forms)

by Jan Bachelor April 4, 2022

Last Updated on April 4, 2022 by Jan Bachelor

Length: 50 minutes|Difficulty: Standard
  1. Create a form such as a ‘Bank import parent form’ with the following suggested fields:
    • Submitee’s name – Single Line Text field- – to track the person’s name since the creating user will be an automation account that submits the form on behalf of the user using REST API.
    • Submitee’s first name – Single Line Text field – a hidden field that will be used in email conversations as part fo the workflow later.
    • User ID – a User field (Gravity Flow required) – to track the ID of the user (all users must have a WordPress account).
    • Nested form (Gravity Nested Forms add-on required) – add the child form we created earlier with the fields that you wish to display.
    • Total – A number field – tick ‘Enable Calculation’ and use a merge tag to calculate individual expenses’ charge amount – for example: {AMEX Expense Reimbursement Sub-form:3:sum=5} –> Child form name:Child form ID:sum=field ID to sum up. See Gravity Nested Form’s Calculations help.
    • Direct Manager’s first name – Single Line Text – a hidden field that will be used when emailing management to approve the submission as part fo the workflow.
    • Direct Manager ID – User field (Gravity Flow required) – a hidden field that will be used to assign a workflow to the user ID in WordPress.
Parent form creation in Gravity Form with a nested (child) form
  1. Prevent users from deleting an imported expense. For this, you will need a custom Javascript code and a free Custom JavaScript add-on from GravityWiz. Once installed, go to the form’s Settings page and enter the following code:
gform.addFilter('gpnf_should_delete', function(shouldDelete, items, $trigger, gpnf) {
	if ( ! $trigger.is('.gpnf-row-actions .delete-button') ) {
		return shouldDelete;
	}

	if ( ! $trigger.data( 'isConfirming' ) ) {
		$trigger
			.data( 'isConfirming', false )
			.text( 'Imported expenses cannot be deleted!' );
			
	

		setTimeout( function() {
			$trigger
				.data( 'isConfirming', false )
				.text( gpnf.modalArgs.labels.delete );
		}, 3000 );

		return false;
	}

	return shouldDelete;
});
Removal of the nested record is not possible from the parent form.
Removal of the entry is not possible from the child form, either (when editing from the parent)
  1. Hide the ‘Add new entry’ button on the form – since we will be importing data from a daily feed from a bank, we do not want employees to be messing with it and adding additional expenses that have not been processed by the bank yet.
    • To do this, install a form of a Code Snippets free plugin in WordPress
    • Create a new snippet with the following code (change form ID to the correct ID of your form) and then activate the plugin.
//Source: https://gravitywiz.com/documentation/gpnf_template_args/   (see add_button)
//Source 2: https://gist.github.com/spivurno/a835d8990d307e1f03dd

// _47 = form ID. If removed, this script will apply also to all other nested forms!
add_filter( 'gpnf_template_args_47', function ( $args, $field ) {
	// Hide the add button for AMEX expenses
	$args['add_button'] = '';	
	
	// Hide the 'Delete entry' button on the parent form. 
        // Note that this is a nested array (array in array). 
        // Hiding the button does not truly hide it and does not hide it from the nested form.
	//$args['labels']['delete_entry']= '';
		
	// Test to remove sticky footer
        // See https://gravitywiz.com/documentation/gpnf_init_script_args/#unstick-the-modal-footer
	//$args['modalStickyFooter'] = false;

    return $args;
}, 10, 2 );
Preview of how the code snippet looks like in WordPress

Verify that the Add button is no longer there:

Before and after the hiding of the Add Expense (Add an entry) button in Gravity Nested Forms
Part 2 - Design the child form for expenses (Gravity Forms)
Part 4a - Integromat Workflow - Fetch data from FTPS and filter it out
Back to: Concur Alternative: Import Employees’ Credit Card Expenses to WordPress via an automated bank feed – Gravity Form/Flow & Make.com (Integromat)

Leave a Comment Cancel Reply

Save my name, email, and website in this browser for the next time I comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 comment 0 FacebookWhatsappEmail

Concur Alternative: Import Employees’ Credit Card Expenses to WordPress via an automated bank feed – Gravity Form/Flow & Make.com (Integromat)

  • Previous
  • Next
Collapse
Expand
  • Part 1 - What do we want to do + Required technology (bank feed)
  • Part 2 - Design the child form for expenses (Gravity Forms)
  • Part 3 - Design the parent form for individual expenses (Gravity Forms)
  • Part 4a - Integromat Workflow - Fetch data from FTPS and filter it out
  • Part 4b - Integromat Workflow - Submit the parent gravity form from Integromat
  • Part 4c - Integromat Workflow - Create child forms in Gravity from Integromat

Search for articles

Other Tips

  • How to mount an NFS share (such as from FreeNAS) from an Android box
  • How to download a Windows 10 ISO on a Windows device – easy work-around

Other Tutorials

  • Build Your Own Router - Proxmox, OPNSense, OpenVPN server and a VPN client all in one!
    12 Steps
  • Dynamically Populate Gravity Forms from Google Sheets (GSheets APIv4)
    6 Steps

Recent Comments

  • Jan Bachelor on Use Integromat to get computer IDs from user email in JamF ProHi Robert, the static groups were created in the p…
  • Robert Petitto on Use Integromat to get computer IDs from user email in JamF ProCan you share how you'd use Make (integromat) to a…
  • Martin on Part 1 – What do we want to do + Required technology (bank feed)This tutorial deserves more credit, I've not seen…
  • Jan Bachelor on WAN / LAN Set Up (Before OPNSense Installation)Hi Ed, I have not tested it with PCI passthrough y…
  • Ed on OPNSense VM Set UpIn step 4 firewall you turned off firewall, should…

Tags

chrome iso windows

Categories

  • Android
  • FreeNAS
  • Linux
  • Windows

Recent Posts

  • How to mount an NFS share (such as from FreeNAS) from an Android box

  • How to download a Windows 10 ISO on a Windows device – easy work-around

Facebook Twitter Instagram Pinterest Linkedin Youtube

@2019 - All Right Reserved. Designed and Developed by PenciDesign

Bachelor Tech
  • Home
  • Tutorials
  • Portfolio
  • About Jan
  • Contact Jan