print table content from related table

Viewing 5 reply threads
  • Author
    Posts
  • February 28, 2025 at 8:18 AM #51660

    Sybille van Zuylen
    Participant

    Hello,
    I’m using tap forms to prepare coaching sessions.
    I have a “session” table which is related to “activity” table.
    Each session has several activities which are numbered in the order I want to do them.
    From there, I am trying to prepare a “session summary” printout to give to the client where all activities and their descriptions are listed in the correct order.
    So I made a new presentation (I’m sorry if the word is not right, I’m using the French translation).

    My problem is I manage to display the “activity” table within the page, but its content is of course cropped in a way that makes it unusable.
    How can I make a well designed text list of the activities related to my “session” record?

    • This topic was modified 1 month ago by Brendan.
    February 28, 2025 at 11:50 PM #51662

    Brendan
    Keymaster

    Hi Sybille,

    On your custom layout, you can adjust the widths of the columns on your Link to Form field to make the related table look a bit nicer. You may also want to print in landscape orientation so you can get more space on the page for your columns.

    What does it currently look like? Can you post a screenshot?

    Thanks,

    Brendan

    P.S. I’m moving this topic out of the Scripting Talk forum because it doesn’t have anything to do with scripting as far as I can tell.

    March 1, 2025 at 3:21 AM #51667

    Sybille van Zuylen
    Participant

    Thank you for your reply.
    Yes I figured I could change the column width, but my problem is that the fields I’d like to display have several lines and I can only get to see the first one.

    See screenshot here: https://snipboard.io/G6RrNd.jpg

    Is there a way to fetch the info from each activity and display their content as a list?

    Thanks for your help!

    March 2, 2025 at 9:30 PM #51672

    Daniel Leu
    Participant

    I don’t know how long your objective description is, but maybe you can use markdown to format it.

    Here’s a field script that fetches all the activities records and formats them as markdown.

    You need to update field ids for the activity form and the respective fields. Additionally, define a summary field in your main form of type markdown.

    When you update an activity record, the summary field is updated. The first line is the number and title, followed by the objective. Unfortunately, TapForm 5’s markdown implementation doesn’t support tables.

    Hope this helps! Bonne chance!

    function Update_Summary() {
    
    	// define the field ids
    	const activities_id = 'fld-xxx';
    	const activities__number_id = 'fld-xxx';
    	const activities__title_id = 'fld-xxx';
    	const activities__objective_id = 'fld-xxx';
    	const summary_id = 'fld-xxx';
    
    	// get activities records
    	let activities = record.getFieldValue(activities_id);
    	
    	let md = "# Activities\n\n";
    		
    	// loop over all activities and create the markdown entries
    	for (activity of activities){
    		let number = activity.getFieldValue(activities__number_id);
    		let title = activity.getFieldValue(activities__title_id);
    		let objective = activity.getFieldValue(activities__objective_id);
    		
    		md += `**${number}: ${title}**   
    ${objective}    
    `;
    	}
    		
    	// update markdown field
    	record.setFieldValue(summary_id, md);
    	document.saveAllChanges();
    }
    
    Update_Summary();
    March 3, 2025 at 12:11 AM #51674

    Brendan
    Keymaster

    Ya, I’m sorry, but the related table can only print a single line of the content. It doesn’t have the ability to increase the height of the row.

    Daniel’s suggestion of creating a field on your parent form that contains the related data in a format that can be printed is a good idea. So you can still use the Link to Form field to enter your content, but have this other field on the parent form that is used for printing that content.

    March 4, 2025 at 7:23 AM #51690

    Sybille van Zuylen
    Participant

    This looks like exactly what I wanted to do, I will give it a go. Thank you so much!

Viewing 5 reply threads

You must be logged in to reply to this topic.