
Announcements
Hello,
I created an advanced form where I fill the different fields. What I want to do is to get the values of those fields and send to my flow to populate a word template.
My problems are :
How do I get the values with my javascript function?
How to add the flow to the "Submit" button to make it work and create my word with the values I give ?
Here is my "function" where i try to console log my value
function callFlow(executionContext)
{
var formContext = executionContext.getFormContext();
//How do i get the value of my field filename from the form?
var filename = formContext.getAttribute("Filename").getValue();
console.log("Test filename -> "+filename);
/*
var params = { } var url = "CUSTOM URL";
var req = new XMLHttpRequest();
req.open("POST", url, true);
req.setRequestHeader('Content-Type', 'application/json');
req.send(JSON.stringify(params));
Xrm.Utility.alertDialog("Flow initiated. The PDF will be sent soon.");
*/
}
Hi @Anonymous ,
i am talking about power apps portals, hope i got the question right 🙂
The attributes on the form have the same id as the logical names in the dataverserse. So, if you have "my_stringattr" as a logical fieldname on your form, you could get the value of it by document.getElemenetByIf("my_stringattr").value .
As you have jQuery on board out of the box i would recommend using $("#my_stringattr").val() .
On listboxes you will get the value of the listbox (usually the numerical value) and on lookups, you have additional inputs which are postfixed with _name and _entityname which carry the expected contents (not sure about the exact names, would have to inspect the dom...)
So, you can gather all the data from the form.
When submit is pressed, two functions are calles, which may be overwriotten by you. Page_ClientValidate and entityFormClientValidate are called by the submitbutton. If one (or both 🙂 ) of these functions exist and return false, the submit is canceled. So, when overwriting it, using return true is not a bad option.
These functions are a good plye to to something while submitting. Two remarks: when you do a post its a fire and forget as the save will navigate away from the page. And these functions are not really documented. I do not know, whether they are simply an overleft from old times and might disappear somewhen.
May be, you just render another button on the form triggering the printout 🙂
May be, its a better idea to make the printaout when the data is saved. Just attach to the saveevent with the flow (i think, it should be possible, i am not a flowexpert)
Does this help in any direction?
Have fun,
Christian