AnsweredAssumed Answered

Form Processor not able to generate form

Question asked by les21 on Jun 5, 2017
Latest reply on Jun 5, 2017 by les21

Hi,

I'm trying to display a custom form using Alfresco.util.PopupManager.displayForm() however I'm having an issue trying to use my own form processor. It works without a hitch if I use the itemKind: "type", so the type processor but if I try to use my own "adduser" processor it just shows a blank form.

 

 

Alfresco.util.PopupManager.displayForm(
    {
        title: "Select Users",
        properties:
        {
            mode: "create",
            itemKind: "adduser",
            itemId: "scwf:adduser",
            showCancelButton: "false"
        },
        success:
        {
            fn: function()
            {
                // do something if successful
            },
            scope: this
        },
        successMessage: "Update of node " + workflowid + " was successful.",
        failure:
        {
            fn: function()
            {
                // do something if failure
            },
            scope: this
        },
        failureMessage: "Update of node " + workflowid + " failed."
    });

The form is defined in xml and I know that my processor is correctly registering because I can see log messages in the console, here is my generate() code in the form processor.

 

 

public Form generate(Item item, List<String> fields, List<String> forcedFields, Map<String,Object> context){
     item.setType("type");
     //we are going to fool it into thinking it's generating a type form, then switch the url under it
     //Form f = super.generate(item, fields, forcedFields, context);
     Form f = new Form(item);
     Item formItem = f.getItem();
        formItem.setType("scwf:adduser");
        formItem.setUrl("/api/classes/scwf_adduser");
     
     logger.debug(f);
     Object itemData = makeItemData(item);
        FormCreationData data = new FormCreationDataImpl(itemData, forcedFields, context);
        populateForm(f, fields, data);
        logger.debug(f);
        FormData de = new FormData();
        de.addFieldData("assoc_scwf_assignees", "");
        f.addField(new PersonField(KEY1_FORM_FIELD, "Attribute key1 - mandatory", "Key1", true));
        f.setFormData(de);
        f.setSubmissionUrl("/share/sidn/workflows/");
        logger.debug("Ye: " + f.getItem());
        logger.debug(f);
       return f;   
    }
protected Object makeItemData(Item item) {
        // Return the attribute item with optionally the value set
        return item;
    }

This code is suppose to be generating a form that looks like the xml definition:

 

<config evaluator="string-compare" condition="scwf:adduser">
  <forms>
   <form>
    <field-visibility>
     <show id="scwf:assignees" force="true" />
    </field-visibility>
    <appearance>
     <set id="" appearance="title" label-id="workflow.set.general" />
     <set id="items" label="Document" />
     <set id="other" label="Review Outcome" />
     <set id="assignee" label-id="workflow.set.assignees" />
     <set id="response" label-id="workflow.set.response" />
     
     <field id="scwf:assignees" label-id="workflow.field.reviewers" set="assignee">
         <control template="/org/alfresco/components/form/controls/authority3.ftl">
       <control-param name="compactMode">false</control-param>
       <control-param name="forceEditable">false</control-param>
      </control>
     </field>
    </appearance>
   </form>
  </forms>
 </config>

 

So in other words it just needs to contain one field, the authority.ftl field (in this case I modified it via form control). What am I doing wrong?

Outcomes