cancel
Showing results for 
Search instead for 
Did you mean: 

Pre-populate Share Form Produced with onActionFormDialog

pjaromin
Champ on-the-rise
Champ on-the-rise
I've created a custom action that sends an email. I've hooked it up in share using 'onActionFormDialog'. Some of the fields should be populated (but editable) by information from the node and the user profile.

I've been reviewing and debugging through this and have a reasonable understanding of the process here. However I can't find an easy way to pre-populate this form.

So if there something built-in here for me to use or do I need to extend the onActionFormDialog javascript or write my own? How would you do this?

Thanks!

- Patrick
3 REPLIES 3

ulisesolivenza
Champ in-the-making
Champ in-the-making
Hello Patrick,

i'm facing exactly the same problem.

¿Does anybody knows how to prepopulate the fields?
By adding they to the ActionBean?

Thank you!!
Ulises

pjaromin
Champ on-the-rise
Champ on-the-rise
I can't say if there's an easier way, but I was unable to find one. So here's what I've done, maybe it will be of use to someone else.

I extended Alfresco.doclib.Actions and the added my own method that calls the onActionFormDialog method first, and then does what I need to populate the form.

Here's some simplified/modified code:


MyPackage.actions.MyFormDialog = {
   onActionMyFormDialog: function mypackage_onActionMyFormDialog(record, owner) {
      this.onActionFormDialog(record,owner);

      // Process, calculate, and then populate the form here
        …
   }   
};
      
YAHOO.extend(MyPackage.actions.MyFormDialog, Alfresco.doclib.Actions);

YAHOO.Bubbling.fire("registerAction",
   {
      actionName: "onActionMyFormDialog",
      fn:  MyPackage.actions.MyFormDialog.onActionMyFormDialog
   }
);


If someone's got a better way, please let me know!

-Patrick

pjaromin
Champ on-the-rise
Champ on-the-rise
Something else that might be of use…

In my case I wanted to pre-populate a couple fields with user information. Although I could have set the repo action up to pull this information as the default, I preferred keep the action "clean" of this logic and force all callers to pass in the appropriate information.

One of the action forms required the user's full name, first and last name concatenated with a space. To solve this I made my own extended "hidden.ftl" form control that takes an additional "eval" parameter which may contain any valid freemarker expression. This expression if present is evaluated first and overrides any other method of retrieving the value.

So my form field config looks like:

<field id="sender-name">
  <control template="/com/myap/components/form/controls/hidden.ftl">
    <control-param name="eval">${user.firstName} ${user.lastName}</control-param>
  </control>
</field>

Then I made modified the first few lines of hidden.ftl to look like:

<#assign fieldValue = "">
<#if field.control.params.eval??>
   <#assign fieldValueTemplate = field.control.params.eval?interpret />
   <#assign fieldValue><@fieldValueTemplate /></#assign>
<#elseif field.control.params.contextProperty??>


This could also be done with the textfield control as I intend for some additional actions, however it's not quite as straightforward to clip the needed code changes to the ftl template here…and I gotten to that part yet.

Again, I'm still rather inexperienced with Alfresco, and especially Share. Most of what I've learned on this is the result of code review and debugging, so I'm not confident there isn't a better way that I've not discovered.

Hope this is helpful.

-Patrick
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.