How to get JSON object in repository webscript, which is passed from aikau page in POST request?

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

How to get JSON object in repository webscript, which is passed from aikau page in POST request?

This is my web console snippet.

My form widget code.

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;
}
// Create the form control for the student
var studentFormWidget = [ {
name : "alfresco/forms/controls/DojoValidationTextBox",
config : {
label : "Student ID",
name : "prop_student_StudentID"
}, {
     name : "alfresco/forms/controls/DojoValidationTextBox",
     config : {
          label : "First Name",
          name : "prop_student_firstName"
     }
}
}];
// Create the form here
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 : "/sample/helloworld",
// To create the folder under document library, we need the
// documberLibrary nodeRer,So POST that too.
alf_destination : alfDestination
},
widgets : studentFormWidget
}
};
// Add the form and services to the JSON MODEL
model.jsonModel = {
widgets : [ form ],
services : [ "alfresco/services/CrudService",
"alfresco/services/NavigationService",
"alfresco/services/UserService",
"alfresco/services/DocumentService"]
};‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

url of repo webscript:  "/sample/helloworld",

How can I get the data passed here in this form

prop_student_studentId  ,  prop_student_firstName

in repository webscript?

3 Replies
redraccoon
Established Member

Re: How to get JSON object in repository webscript, which is passed from aikau page in POST request?

I didn't understand where you want to use your payload

For a similar probleme I did a custom widget

for example to get the label of my textBox 

this.serviceXhr({
url : AlfConstants.PROXY_URI + "your_webscript_repo_url",
method: 'GET',
responseTopic: "REPONSE_TOPIC",
successCallback: this.loadPropertiesXhr,

callbackScope: this <==== that's your payload

});

loadPropertiesXhr: function blabla_loadPropertiesXhr(response) {
console.log(response);

this.statutLabel.setValue(response.properties[0].statut);

}

hardik1512
Established Member II

Re: How to get JSON object in repository webscript, which is passed from aikau page in POST request?

Hello,

If your goal is to submit form and create a node of your custom type,

In publish payload url instead of your web script url specify:

url : "api/type/<<your-type>>/formprocessor",

This will submit form and create node is specified location.

mbajpai
Active Member II

Re: How to get JSON object in repository webscript, which is passed from aikau page in POST request?

If your repository webscript has the contoller written in Java , it will receive the payload in the variable request.getContent().getContent(). You can further parse the JSON object to retrieve the values .