Including parameters with gsftSubmit?

Stephen W_
Giga Guru

When running UI Actions, gsftSubmit can be used to execute the serverside section of your script after the client-side portion has been run.

However, there seems to be a glarin omission from the documentation.     gsftSubmit.

It's used on many OOB ui actions, but no documentation in the wiki.

Example:
I want to collect a value from the user with a client action and use it along with current.somevalue.

If I am able to include a parameter in that gsftSubmit, (and consume it in the ui action) it makes this very clean.  

Otherwise, I'm thinking I can use g_scratchpad..

On a related note, I also see in the library: gsftPrompt, gsftConfirm, and gsftListSubmit.

Has anyone used these or know where I can find documentation/examples?

Thanks,

-Stephen

9 REPLIES 9

adiddigi
Tera Guru

A very valid point indeed. Sadly we don't have documentation for this function. But you can see the entire function declaration on your browser:



function gsftSubmit(control,   form,   action_name) {


var f;


if (typeof form == "undefined") {


f = findParentByTag(control, 'form');


if (typeof form == "undefined") {


var sectionFormId = $("section_form_id");


if (sectionFormId)


f = $(sectionFormId.value);


}


} else


f = form;


if (g_submitted)


return false;


if (typeof action_name == "undefined" && control)


action_name = control.id;


if (action_name == 'sysverb_delete') {


if   (!confirm(getMessage("Delete this record") + "?")) {


g_submitted = false;


return false;


}


}


f.sys_action.value=action_name;


if (typeof f.onsubmit == "function" && action_name != 'sysverb_back') {


var rc = f.onsubmit();


if (rc === false) {


g_submitted = g_form.submitted = false;


return false;


}


}


if (control && control.getAttribute('gsft_id')) {


action_name = control.getAttribute('gsft_id');


f.sys_action.value=action_name;


}


if (action_name == 'sysverb_back')


g_submitted = false;


else


g_submitted = true;


if (typeof g_form != 'undefined' && g_form && g_submitted)


g_form.enableUIPolicyFields();


CustomEvent.fire("glide:form_submitted");


try {


f.submit();


} catch (ex) {


if (ex.message.indexOf('Unspecified') == -1)


throw ex;


}


return false;


}



If you probably search the source, you will get examples of invocations which will eventually help you understand this function yourself. I think I tried to fig this out in 2013, but don't remember most of it, so good luck.




I'm sorry I cannot help but remember this (parody)beauty from Star Wars:



Read-the-source-luke


Thanks Abhiram,


I must admit, I was really hoping for the "I already do this, and here's how", answer.



Unfortunately, the somewhat bizarre combination of server/client code in ui actions don't appear to leave room for passing any parameter.
Even if I were to override gsftSubmit to add an additional parameter, I'm not sure how I would consume that.



Re. g_scratchpad, when attempting to add a variable to it from the client to pass to the server, I find that g_scratchpad does not exist.     Can I create that from the client to be visible to the server or is this something that will only work in one direction?


No you cannot. You can only pass it on from Server Side to client. Because the display business rules runs before any client script, you will not be able to pass anything from CS to Server side.


Slava Savitsky
Giga Sage

Hi Stephen,


I have stumbled upon the same problem just now. Have you found any workaround for it?