in understanding now, 1 doget() can trigger unique dopost() in google apps script application.
i perform software publisher system user upload file or fill revision information in forms , push submit next step. final page show input information, send email guys , complete operation.
but how enter next form after submit button pushed?
i have tried method creating 2nd step , 3rd step forms in dopost(), , using try...catch difference step form triggered current step, following code. (because steps can't callback item throw non-previous step, arises exception)
it works think doesn't make sens , silly. have better solutions? thanks, please.
//--------------------------------------------------------------------------- function doget(e) { var app = uiapp.createapplication().settitle("ap publisher"); createfileuploadform(app); return app; } //--------------------------------------------------------------------------- function dopost(e) { var app = uiapp.getactiveapplication(); try { // 2nd step form var fileblob = e.parameter.thefile; createrevisionform(); } catch(error) { try { // 3rd step form createconfirmform(e); } catch(error2) { //complete sendmail(e); modifysitepagecontent(e); savehistoryfile(e); showconfirmedinfo(e); } } return app; }
this answer copied entirely create new page in form dynamically, based on data of prev. page.
using uiapp
service, have 1 doget()
, 1 dopost()
function... here's way extend them support dynamic multi-part form. (the example code borrowed this answer.)
your doget()
builds part1 of form. in form, however, need identify form by name, this:
var form = app.createformpanel().setid("emailcopyform");
you dopost()
then, pass off handling of post operation different functions, depending on form has been submitted. see below. (also included: reportformparameters ()
, default handler display data collected form part.)
/** * dopost function multi-form handling. individual form handlers must * return uiapp instances. */ function dopost(eventinfo) { var app; logger.log("form id = %s", eventinfo.parameter.formid); // call appropriate handler posted form switch (eventinfo.parameter.formid) { case 'emailcopyform': app = postemailcopyform(eventinfo); break; default: app = reportformparameters (eventinfo); break; } return app; } /** * debug function - returns uiinstance containing parameters * provided form event. * * example of use: * <pre> * function dopost(eventinfo) { * return reportformparameters(eventinfo); * } * </pre> * * @param {event} eventinfo event uiapp form submission * * @return {uiinstance} */ function reportformparameters (eventinfo) { var app = uiapp.getactiveapplication(); var panel = app.createverticalpanel(); panel.add(app.createlabel("form submitted")); (var param in eventinfo.parameter) { switch (param) { // skip noise; these keys used internally uiapp case 'lib': case 'appid': case 'formid': case 'token': case 'csid': case 'mid': break; // report parameters named in form default: panel.add(app.createlabel(" - " + param + " = " + eventinfo.parameter[param])); break; } } app.add(panel); return app; }
to generate each form part, subsequent form handlers can use data retrieved in previous parts dynamically add new form objects ui.
Comments
Post a Comment