Print selected record with its childs

Hi team,

This is what I looking for: Select the Countries and print the related info of each one:
2X_0_0e69655254a1fb37f235b86de7b2188eba6d46c9.png

I was trying to follow this great topic by @Suvrutt_Gurjar

I have table “Countries” with fields:

  • Country (key column)
  • Image
  • SendReport
  • Related Overview (virtual column)

And table “Overview” with fields

  • Country (key column and related with “Country” table)
  • Care
  • Country of origin
  • Language

I have this action to fire the workflow:

this is the workflow:

  • target data: Countries
  • Update event: UPDATES_ONLY
  • If this is true => Condition:
    • AND(ISNOTBLANK([_THISROW_AFTER].[SendReport]),
      [_THISROW_BEFORE].[SendReport] <> [_THISROW_AFTER].[SendReport]
      )

This is my gDoc template:

And these are my issues:

  • the Header of my template is not repeating for next pages.
  • I am getting an email with its attachment per selected Country
  • The attached show me all the list of Countries of the table (not the only ones I selected), and repeating the data of Country where I fired the action:

As I told I was trying to follow the topic mentioned above, but if any of you have a better idea to get what I am needing, I will appreciate, many thanks in advance, guys!

Solved Solved
1 36 2,762
1 ACCEPTED SOLUTION

I just quickly created a sample app to share my idea to set up Apps to manage

  1. Select the name of countries (enumlist)
  2. Fire the email workflow to generate the tables / list of “selected” countries alone together with each child records associated with each country.

The approach is different from one which have been discussed earlier on this thread, but let the user to select the country through the FORM (rather than select ones over the Deck view and trigger the bulk actions), and then saving form will fire the workflow to submit email with attachment to the log in user.

This is little complicated tricks, so please copy my sample app and look inside.

Sample app is right here.

https://www.appsheet.com/samples/Sample-App?appGuidString=bd70d37c-ccc1-4ce0-899f-6f735d4035f0

here is sample for sample PDF which is generated by this sample app.

@Geovany_Kelly
@Suvrutt_Gurjar
@Phil
@Aleksi

View solution in original post

36 REPLIES 36

Headers are not supported see topic “Page Headers, Page Footers, and Page Numbering are Not Supported” in this article https://help.appsheet.com/en/articles/2993197-google-docs-email-templates

@Geovany_Kelly ,

Could you mention ,if the action that you have shown in the first picture in your post where user selects the records for printing or for the report is “Send Report” action that you have described in detail later?

Correct, is the same, thar action updates the column “SendReport” from the Countries table.

Hi @Geovany_Kelly ,

Thank you. So are you getting 3 reports emails for example , if you select three records?

I believe your group by logic is overall working but since your selection of rows is not reaching the template exression, because your action is “Send Report” and not “Select Rows” ,you are seeing all the countries in your report.

Also I believe you need two additional actions to select/ deselct the recrods for the report, may be with a new column called, say [Selected in Report] in Overview table with enum statuses Yes/No, You may then set this column with two complementary actions ( say “Select in Report” and “Remove from Report” that show up and act alternatively. So through this action “Select in Report”, you may set the column [Selected in Report] to “Yes” and with action “Remove from Report”, you may set the column [Selected in Report] to “No”

Now in the ourter loop you may have an expression something like

<<Start: SELECT(Overview[Country], [Selected in Report]=“Yes”)>>

Then you may fire “Send Report” action from any one row in the country records.

This process may be further optimized but I believe you get an idea.I hope this helps.

Hi @Suvrutt_Gurjar,

I added the new column “Selected in Report” (Yes/No), just for testing I am manually editing it from the app and value is set to “TRUE” in the gSheet.

But I am still getting 1 email with its report per Country that has TRUE in the “Selected in Report” column. And still getting all the list of Countries, not only the ones with TRUE in the “Selected in Report” column.

I changed the condition of the workflow to send the email but not sure if I am doing something wrong here:

and this is the template with your suggestion:

thanks in advance for taking time helping.

You should still use the same condition rule than earlier like AND(ISNOTBLANK([SendReport]),[_THISROW_BEFORE].[SendReport]<>[_THISROW_AFTER].[SendReport]). At this moment your Workflow is triggered every time when you set the [Selected in Report] as TRUE.

Hi @Geovany_Kelly

As rightly guided by @Aleksi, your condition for firing report should be same as earlier.

The additional column suggested is just for selecting the records per your choice.

I set it back with that formula, is still sending me all the list of countries, and as always repeating the info of the Country that has value in the “SendReport” column:
2X_7_7b574a85abae21fbdc9b36dec40bfa2c964b0922.png

right now I did this test: I selected Belgium, Bolivia (Belgium already has value in SendReport column) but I clicked the action “Send report” from record “Brazil”
2X_7_781dde88e5d69ebe5a65158bed3c0ab430a0e72d.png

and the report comes empty. I suppose it’s because Brazil has empty the “Selected in report” column.

Hi @Geovany_Kelly,

Your selected in report column is showing TRUE in the database.
SoI believe you are using a Y/N type column that stores TRUE for Y and FALSE for N in the database.

however it looks like your template expression is still

<<Start: SELECT(Overview[Country], [Selected in Report]=“Y”)>>

Could you please try with
<<Start: SELECT(Overview[Country], [Selected in Report]=TRUE)>>

Hi @Suvrutt_Gurjar,

it’s correct, those are the values and column type. I just tried that expression
<<Start: SELECT(Overview[Country], [Selected in Report]=TRUE)>>

and testing with only 1 country, but still getting the attached file with all countries, not for the specific one. I am not sure what I am missing.

you have to consider the completely different approach to achieve your goal, I guess.

Hi @tsuji_koichi,

That’s for sure. I just don’t have many experience with reports and actions, not sure if maybe someone in the community can create a simple sample app with this case would be better.

Sure, i just read and access to the thread you opened up here, my impression was you cant achieve your goals by doing what you are trying to do with Appsheet, so I suggested to consider to have a different approach.

Nothing is impossible with Appsheet. But the danger is to stick with one approach, while we may have other approach to end up with the same result.

Yes, this is complicated and challenging subject, but that s why it is interesting.

Appsheet surely can manage to deal with your unique requirement, I believe, for sure, but to see the same thing, sometime we need to see the same from the different approach and/or angles.

We may sacrifice one thing during the new process, but as far as we are able to achieve the goal, it should not be a matter.

Hi @tsuji_koichi,

Thank you for your valuable inputs. As always, I respect your evaluation and inputs.

Hi @Geovany_Kelly,

Since I participated in this post thread , requesting you to do certain steps, I feel obliged to work more on this requirement. I will be glad to work with you further on this to the best of my ability. I propose following

I will go through this entire post thread again and try to revert with some approach, if feasible and within my capacity. I may have more queries to you during this time. Also since this thread has become substantially long , we may take it offline through mesaging service of this portal and post approach , if found, later for reference here. We may request community experts’ guidance, if required, in between.

Of course,as @Phil has guided, please note that we will not be working on pagination, headers, footers etc.

I am sorry that I need to call it a day as it is late night at my place. However, I will be willing to work on this tomorrow. Request let me know your thoughts.

I will revert tomorrow as well nigh nigh.

Thank you @tsuji_koichi- that will be great.

Thanks all for replying, and both @Suvrutt_Gurjar, @tsuji_koichi

really appreciate for taking time to help on this. That kind of attitude has been key to make AppSheet a great platform to develop Apps.

I will continue testing and pending of any comments to get this solved. Thanks again, guys.

I just quickly created a sample app to share my idea to set up Apps to manage

  1. Select the name of countries (enumlist)
  2. Fire the email workflow to generate the tables / list of “selected” countries alone together with each child records associated with each country.

The approach is different from one which have been discussed earlier on this thread, but let the user to select the country through the FORM (rather than select ones over the Deck view and trigger the bulk actions), and then saving form will fire the workflow to submit email with attachment to the log in user.

This is little complicated tricks, so please copy my sample app and look inside.

Sample app is right here.

https://www.appsheet.com/samples/Sample-App?appGuidString=bd70d37c-ccc1-4ce0-899f-6f735d4035f0

here is sample for sample PDF which is generated by this sample app.

@Geovany_Kelly
@Suvrutt_Gurjar
@Phil
@Aleksi

Hey @tsuji_koichi!

That was brilliant! Definitely that is a solution for this topic using another approach!

You know, I will try to take some of your app logic to adapt it to my original approach, I will try to use the same action when selecting, then when click the action button will add the countries to a new table “Print” and finally trigger the email when ADD_ONLY for that “Print” table. I will try and keep you posted.

Again, thank you so much guys!
@Suvrutt_Gurjar Many, many thanks!
@Phil
@Aleksi

Yes, this is just ONE approach to reach out to the goal, and there should be another different approaches and workaround.

Take just an essence out of this sample and implement nice feature and function to your own app.

Let me know if you need more help on this topics.

Thanks @tsuji_koichi, just one doubt, following your sample app, would perfectly works if there are multiple users printing? Question, the app as it is, would it print what each user selected?

Yes, off course.

Each login user will not be bothered by other users.

Setting (in this case, selection) is always owned by the login users. You see useremail() expression in the print table, where we capture who made and save new form. And security setting for this table, we only read the row with email value which matches with login user.

Gotcha! I just seen it. Alright, I don’t bother you more for now haha, I will test with my approach and let you know.

Thanks again, @tsuji_koichi

Please take your own time to look deep inside my sample app to see all the anatomy!!!
You will find it is not super complicated, just logical.

Enjoy my sample app haha.

Hi @tsuji_koichi,

Thank you so much. Will test it soon.

@Geovany_Kelly has mentioned it works as per his requirement. Well done @tsuji_koichi

Thank you to @Aleksi and @Phil as well. Your insights are always practical and very guiding for us.

I just threw a different spice to get different flavor

Hi @tsuji_koichi,

I copied and browsed your app. Neat , clean implemenation indeed. Basically you separated printing selection into another table and then attached the selection status back to data source tables and then a clever use of slice of selected countries for the template. Very neat work indeed.

Correct.
You might read the descriptions I stated on the sample app page. Basically, we are missing sort of “state management” system within Appsheet. Meaning we are not able to store the particular data temporarily on the browser storage. For instance, the values of enumlist being selected by each users, we are not able to store those values in the app. That is the problem. To solve this, UserTable kinda of arrangement should solve, but on this particular case, I capture the values and store as a set of table, but we dont need the last values which need to be ruled out. Old selection of the countries in this case are kept saved in the table, but we wont use any longer, only need the most latest row and its value.

The trick is boiling down to a single expression within VC in country table like this.

IN(
[Country],
any
(
select(print[SelectedCountry],[TimeStamp]=max(select(print[TimeStamp],useremail()=[UserEmail])))

)
)

Simple expression isnt it?

To store the most latest “selected country values as list type”, just slice the table to get the single row with max, timestamp value etc.

Actually, we are not OVERWRITING this latest value all the time new form is generated. It could be possible we prepare the unique rows for printing table for each login users, and they keep refresh and updating the selection and then fire workflow, but my workaround should be better to do the same.

Actually we are able to use this tricks for another purpose and use case as well.

I m calling this trick as “Appsheet state management system”

Javascript liberary, angular, vue, react, they do have own state management system to develop single web page application (SPA), i just borrow such technique to implement into the Appsheet.

Hey @tsuji_koichi just a little bug I found, if possible make the update in your sample app, so developer don’t lose the mind as I did minutes ago haha.

Column “TimeStamp” from “Print” table change the column type from Time to DateTime, only that.

Let me explain why, since for now you are only saving the time and selecting the countries with the max TimeStamp, it would be issue if the same user print in the night, and maye print next day morning:

give it a look, the last print I submitted was at “0:58:47” but the formula returns the max time: “19:43:08”
2X_9_9055e51945613beac98279eb7c3697206f9a63f0.png

after change and working like a charm:
2X_6_64077642d9d02dd27353082a3bf570a659ba5eb3.png

Sorry, i forgot to change the data type to DateTime. I just updated my sample.

In terms of your mail template, I understand start end expression is only valid for list/table style only, but I m not entirely sure.

By the way the current report is working fine:

But how if I want data like this:

I am not getting any email none attachment. Am I doing something wrong?

Just worth trying.

What s gonna happen if you change the template like this?

2X_f_f0fbd17ed00023d9538525ef3105ef8892b2c22d.png

Move start end expression outside table and sandwich the whole table?

I know it was something easy for you, that worked! Thanks @tsuji_koichi!

Wow! Great!

@Suvrutt_Gurjar
@Geovany_Kelly

Hi Guys, I think there are quite useful tips we discussed and managed to get, which should be placed with “tips and tricks” flags so that people can find rather easily.

I will do that job later on, just simply create new threads and place link to this post.

When I go to that link I don’t see a Download a Copy or a look Under the Hood for that app. How can I access it? I think it will help solve a problem I have.

Thanks.

Top Labels in this Space