AnsweredAssumed Answered

401 error in aikau while making Repo request

Question asked by muralidharand on Dec 12, 2016
Latest reply on Dec 13, 2016 by kalpesh.c2

I was trying to help the below quention, with a simple example. could-anyone-provide-aikau-form-example-with-data-loading

 

Basically, I would do a repo request when the form dialog loads and wanted to display the document libray noderef in the dialog. So I called makeRepoRequest() during dialog load, but the network tab throws 401 error.

 

Please let me know, what is wrong with this sample?

 

/* studentForm.get.js */
function makeRepoRequest()
{
    var alfDestination = "something";


    var site = page.url.templateArgs.site;
    var result = remote.call("/slingshot/doclib/container/" + site + "/documentLibrary");
    return result.status.code;
    if (result.status.code == status.STATUS_OK) {
        alfDestination = JSON.parse(result).container.nodeRef;
    }
}

var formControls = [
  {
    name: "alfresco/forms/controls/TextBox",
    config: {
      name: "name1",
      label:"Name",
      placeHolder:"Enter Name Here",
      visibilityConfig: {
        initialValue: true
      }
    }
  },
  {
    name: "alfresco/forms/controls/TextBox",
    config: {
      label:"Age",
      name: "age",
      placeHolder:"Enter Age Here",
      visibilityConfig: {
        initialValue: true
      }
    }
  }
  ,
  {
    name: "alfresco/forms/controls/TextBox",
    config: {
      label:"NodeRef",
      name: "nodeRef",
      visibilityConfig: {
        initialValue: true
      },
      value : makeRepoRequest()
    }
  }
];

var showDialog = {
  name: "alfresco/buttons/AlfButton",

  config: {
    readOnly:"true",
    id:"dialog1",
    label: "Create New Student",
    additionalCssClasses: "call-to-action",
    publishTopic: "ALF_CREATE_FORM_DIALOG_REQUEST",
    publishPayloadType: "PROCESS",
    publishPayload: {
      dialogTitle: "Student Form",
      dialogConfirmationButtonTitle: "Register",
      dialogCancellationButtonTitle: "Cancel",
      formSubmissionTopic: "ALF_CRUD_CREATE",
      formSubmissionPayloadMixin: {
        url: "api/type/cm%3Astudent/formprocessor"
      },
      fixedWidth: true,
      widgets: formControls
    }
  }
};

model.jsonModel = {
widgets :[showDialog
         ],
services : [
            "alfresco/dialogs/AlfDialogService",
            "alfresco/services/CrudService"
        ]    
};

Outcomes