Post Request

cancel
Showing results for 
Search instead for 
Did you mean: 
riadhazzouz
Active Member

Post Request

I made this model 

<types>
      <type name="sp:configuration">
            <title>Configuration</title>
            <parent>cm:content</parent>
            <properties>
                  <property name="sp:username">
                        <type>d:text</type>
                        <mandatory>true</mandatory>
                  </property>
                  <property name="sp:users">
                        <type>d:text</type>
                        <multiple>true</multiple>
                  </property>
            </properties>
      </type>
</types>

I' m trying to make a form in which a user can choose a list of users, I tried this code in the js file of the new page

ConfigurationFormWidget = [
{
      name : "alfresco/forms/controls/MultiSelectInput",
      config : {
            label : "Select Users",
            name : "prop_config_users",
            optionsConfig : {
                  queryAttribute : "shortName",
                  publishTopic : "ALF_GET_FORM_CONTROL_OPTIONS",
                  publishPayload : {
                        url : page.url.context
                        + "api/groups/ALFRESCO_ADMINISTRATORS/children",
                  resultsProperty : "options",
                  itemsAttribute : "data",
                  labelAttribute : "displayName",
                  valueAttribute : "shortName"
                  }
            }
      }
}];

var form = {
      name: "alfresco/forms/Form",
      config: {
            showOkButton: true,
            okButtonLabel: "Save",
            showCancelButton: false,
            cancelButtonLabel: "",
            //Specify the TOPIC here
            okButtonPublishTopic: "ALF_CRUD_CREATE",
            okButtonPublishGlobal: true,
            okButtonPublishPayload: {
                  //Specify the URL here to POST the data
                  url: "/hdp/ws/configUserSpace",
                 //To create the folder under document library, we need the documberLibrary nodeRef,So POST that too.
                  alf_destination:alfDestination
            },
      widgets: ConfigurationFormWidget
      }
};

model.jsonModel.widgets.push(form);
/*************************************************************************************/

the issue is that the users are not being displayed in the MultiSelectInput, and I didn't find the URI to display all users not only ALFRESCO_ADMINISTRATORS.

Finally how can I make the POST request to send the data and save it in contents?

1 Reply
riadhazzouz
Active Member

Re: Post Request

How can I change this code to make the alfDestination variable equal to companyHome , is it possible ?

var site = page.url.templateArgs.site;
 //Read the node reference of Document Library
 var alfDestination = null;
 var result = remote.call("/slingshot/doclib/container/"+site+"/documentLibrary");
 if (result.status.code == status.STATUS_OK) 
{    alfDestination = JSON.parse(result).container.nodeRef; }