cancel
Showing results for 
Search instead for 
Did you mean: 

Sending aikau form in json format

hdalang
Champ in-the-making
Champ in-the-making

hey community, I want to use json format in sending data to alfresco so I have developed my form in aikau and I'm sending my data as webscript to some url defined before, the code of the form is shown here:

<code>

{

  name : "alfresco/forms/Form",

  config : {

  okButtonPublishTopic : "ALF_CRUD_CREATE",

  okButtonLabel : "Submit",

  showValidationErrorsImmediately : false,

  widgets : [

  {

  name : "alfresco/forms/controls/TextBox",

  config : {

  fieldId : "student-name",

  label : "Student Name",

  placeHolder : "Enter your name",

  name : "student-name",

  requirementConfig : {

  initialValue : true

  }

  }

  },

  {

  name : "alfresco/forms/controls/TextBox",

  config : {

  fieldId : "student-card-no",

  label : "Student Card Number",

  placeHolder : "Enter your card number",

  name : "student-card-no",

  type : "number",

  validationConfig : [ {

  "validation" : "regex",

  "regex" : "^[0-9]+$",

  "errorMessage" : "Numbers only"

  } ],

  requirementConfig : {

  initialValue : true,

  rules : [ {

  targetId : "SHOW",

  is : [ true ]

  } ]

  }

  }

  },

  {

  name : "alfresco/forms/controls/Select",

  config : {

  fieldId : "student-college",

  label : "Student College",

  name : "student-college",

  optionsConfig : {

  fixed : [ {

  label : "Faculty of Sharia",

  value : "FACULTY OF SHARIA"

  }, {

  label : "Faculty of Education",

  value : "FACULTY OF EDUCATION"

  }, {

  label : "Faculty of Arts",

  value : "FACULTY OF ARTS"

  }, {

  label : "Faculty of  Ecnomic",

  value : "FACULTY OF ECONOMIC"

  }, {

  label : "Faculty of Sciences",

  value : "FACULTY OF SCIENCES"

  }, {

  label : "Faculty of Computer",

  value : "FACULTY OF COMPUTER"

  }, {

  label : "Faculty of Engineering",

  value : "FACULTY OF ENGINEERING"

  }, {

  label : "Faculty of Medicine",

  value : "FACULTY OF MEDICINE"

  }, {

  label : "Faculty of Pharmcy",

  value : "FACULTY OF PHARMCY"

  }, {

  label : "Faculty of  Nursing",

  value : "FACULTY OF NURSING"

  }, {

  label : "Faculty of Oral",

  value : "FACULTY OF ORAL"

  }, {

  label : "Faculty of Metals",

  value : "FACULTY OF METALS"

  }, {

  label : "Faculty of Communications",

  value : "FACULTY OF COMMUNICATIONS"

  }, {

  label : "Faculty of  Laboratory",

  value : "FACULTY OF LABORATORY"

  }, {

  label : "Faculty of Islamicstudies",

  value : "FACULTY OF ISLAMICSTUDIES"

  }, {

  label : "Faculty of Agriculture",

  value : "FACULTY OF AGRICULTURE"

  } ]

  }

  }

  },

  {

  name : "alfresco/forms/controls/TextBox",

  config : {

  fieldId : "student-phone-no",

  label : "Student Phone Number",

  placeHolder : "Enter your phone number",

  name : "student-phone-no",

  requirementConfig : {

  initialValue : true

  },

  validationConfig : [ {

  "validation" : "regex",

  "regex" : "^[0-9]+$",

  "errorMessage" : "Numbers only"

  } ]

  }

  },

  {

  name : "alfresco/forms/controls/TextBox",

  config : {

  fieldId : "email",

  label : "Email",

  placeHolder : "Enter your email",

  name : "email",

  validationConfig : [ {

  validation : "regex",

  regex : "^([0-9a-zA-Z]([-.w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-w]*[0-9a-zA-Z].)+[a-zA-Z]{2,9})$",

  errorMessage : "Valid E-mail Address Required"

  } ],

  requirementConfig : {

  initialValue : true

  }

  }

  },

  {

  name : "alfresco/forms/controls/Select",

  config : {

  fieldId : "COUNTRY",

  label : "Country",

  description : "Select your Country",

  name : "country",

  optionsConfig : {

  fixed : [

  {

  label : "Afghanistan",

  value : "AFGHANISTAN"

  },

  {

  label : "Albania",

  value : "ALBANIA"

  },

  {

  label : "American Samoa",

  value : "AMERICAN SAMOA"

  },

  {

  label : "Andorra",

  value : "ANDORRA"

  },

  {

  label : "Angola",

  value : "ANGOLA"

  },

  {

  label : "Anguilla",

  value : "ANGUILLA"

  },

  {

  label : "Antarctica",

  value : "ANTARCTICA"

  },

  {

  label : "Antigua and Barbuda",

  value : "ANTIGUA AND BARBUDA"

  },

  {

  label : "Argentina",

  value : "ARGENTINA"

  },

  {

  label : "Armenia",

  value : "ARMENIA"

  },

  {

  label : "Aruba",

  value : "ARUBA"

  },

  {

  label : "Australia",

  value : "AUSTRALIA"

  },

  {

  label : "Austria",

  value : "AUSTRIA"

  },

  {

  label : "Azerbaijan",

  value : "AZERBAIJAN"

  },

  {

  label : "Bahamas",

  value : "BAHAMAS"

  },

  {

  label : "Bahrain",

  value : "BAHRAIN"

  },

  {

  label : "Bangladesh",

  value : "BANGLADESH"

  },

  {

  label : "Barbados",

  value : "BARBADOS"

  },

  {

  label : "Belarus",

  value : "BELARUS"

  },

  {

  label : "Belgium",

  value : "BELGIUM"

  },

  {

  label : "Belize",

  value : "BELIZE"

  },

  {

  label : "Benin",

  value : "BENIN"

  },

  {

  label : "Bermuda",

  value : "BERMUDA"

  },

  {

  label : "Bhutan",

  value : "BHUTAN"

  },

  {

  label : "Bolivia",

  value : "BOLIVIA"

  },

  {

  label : "Bosnia and Herzegovina",

  value : "BOSNIA AND HERZEGOVINA"

  },

  {

  label : "Botswana",

  value : "BOTSWANA"

  },

  {

  label : "Bouvet Island",

  value : "BOUVET ISLAND"

  },

  {

  label : "Brazil",

  value : "BRAZIL"

  },

  {

  label : "British Indian Ocean Territory",

  value : "BRITISH INDIAN OCEAN TERRITORY"

  },

  {

  label : "Brunei Darussalam",

  value : "BRUNEI DARUSSALAM"

  },

  {

  label : "Bulgaria",

  value : "BULGARIA"

  },

  {

  label : "Burkina Faso",

  value : "BURKINA FASO"

  },

  {

  label : "Burundi",

  value : "BURUNDI"

  },

  {

  label : "Cambodia",

  value : "CAMBODIA"

  },

  {

  label : "Canada",

  value : "CANADA"

  },

  {

  label : "Cape Verde",

  value : "CAPE VERDE"

  },

  {

  label : "Cayman Islands",

  value : "CAYMAN ISLANDS"

  },

  {

  label : "Central African Republic",

  value : "CENTRAL AFRICAN REPUBLIC"

  },

  {

  label : "Chad",

  value : "CHAD"

  },

  {

  label : "Chile",

  value : "CHILI"

  },

  {

  label : "China",

  value : "CHINA"

  },

  {

  label : "Christmas Island",

  value : "CHRISTMAS ISLAND"

  },

  {

  label : "Cocos (Keeling) Islands",

  value : "COCOS (KEELING) ISLANDS"

  },

  {

  label : "Colombia",

  value : "COLOMBIA"

  },

  {

  label : "Comoros",

  value : "COMOROS"

  },

  {

  label : "Congo",

  value : "CONGO"

  },

  {

  label : "The Democratic Republic of The Congo",

  value : "THE DEMOCRATIC REPUBLIC OF THE CONGO"

  },

  {

  label : "Cook Islands",

  value : "COOK ISLANDS"

  },

  {

  label : "Costa Rica",

  value : "COSTA RICA"

  },

  {

  label : "Cote D’ivoire",

  value : "COTE D’IVOIRE"

  },

  {

  label : "Croatia",

  value : "CROATIA"

  },

  {

  label : "Cuba",

  value : "CUBA"

  },

  {

  label : "Cyprus",

  value : "CYPRUS"

  },

  {

  label : "Czech Republic",

  value : "CZECH REPUBLIC"

  },

  {

  label : "Denmark",

  value : "DENMARK"

  },

  {

  label : "Djibouti",

  value : "DJIBOUTI"

  },

  {

  label : "Dominica",

  value : "DOMINICA"

  },

  {

  label : "Dominican Republic",

  value : "COOK ISLANDS"

  },

  {

  label : "Ecuador",

  value : "ECUADOR"

  },

  {

  label : "Egypt",

  value : "EGYPT"

  },

  {

  label : "El Salvador",

  value : "EL SALVADOR"

  },

  {

  label : "Equatorial Guinea",

  value : "EQUATORIAL GUINEA"

  },

  {

  label : "Eritrea",

  value : "ERITREA"

  },

  {

  label : "Estonia",

  value : "ESTONIA"

  },

  {

  label : "Ethiopia",

  value : "ETHIOPIA"

  },

  {

  label : "Falkland Islands (Malvinas)",

  value : "FALKLAND ISLANDS (MALVINAS)"

  },

  {

  label : "Faroe Islands",

  value : "FOROE ISLANDS"

  },

  {

  label : "Fiji",

  value : "Fiji"

  },

  {

  label : "Finland",

  value : "FINLAND"

  },

  {

  label : "French Guiana",

  value : "FRENCH GUIANA"

  },

  {

  label : "French Polynesia",

  value : "FRENCH POLYNESIA"

  },

  {

  label : "French Southern Territories",

  value : "FRENCH SOUTHERN TERRITORIES"

  },

  {

  label : "Gabon",

  value : "GABON"

  },

  {

  label : "Gambia",

  value : "GAMBIA"

  },

  {

  label : "Georgia",

  value : "GEORGIA"

  },

  {

  label : "Estonia",

  value : "ESTONIA"

  },

  {

  label : "Germany",

  value : "GERMANY"

  },

  {

  label : "Ghana",

  value : "GHANA"

  },

  {

  label : "Gibraltar",

  value : "GIBRALTAR"

  },

  {

  label : "Greece",

  value : "GREECE"

  },

  {

  label : "Greenland",

  value : "GREENLAND"

  },

  {

  label : "Grenada",

  value : "GRENADA"

  },

  {

  label : "Guadeloupe",

  value : "GUADELOUPE"

  },

  {

  label : "Guam",

  value : "GUAM"

  },

  {

  label : "Guatemala",

  value : "GUATEMALA"

  },

  {

  label : "Guinea",

  value : "GUINEA"

  },

  {

  label : "Guinea bissau",

  value : "GUINEA BISSAU"

  },

  {

  label : "Guyana",

  value : "GUYANA"

  },

  {

  label : "Haiti",

  value : "HAITI"

  },

  {

  label : "Heard Island and Mcdonald Islands",

  value : "HEARD ISLAND AND MCDONALD ISLANDS"

  },

  {

  label : "Holy See (Vatican City State)",

  value : "HOLY SEE(VATICAN CITY STATE)"

  },

  {

  label : "Honduras",

  value : "HONDURAS"

  },

  {

  label : "Hong Kong",

  value : "HONG KONG"

  },

  {

  label : "Hungary",

  value : "HUNGARY"

  },

  {

  label : "Iceland",

  value : "ICELAND"

  },

  {

  label : "India",

  value : "INDIA"

  },

  {

  label : "Indonesia",

  value : "INDONESIA"

  },

  {

  label : "Islamic Republic of Iran",

  value : "ISLAMIC REPUBLIC OF IRAN"

  },

  {

  label : "Iraq",

  value : "IRAQ"

  },

  {

  label : "Ireland",

  value : "IRELAND"

  },

  {

  label : "Israel",

  value : "ISRAEL"

  },

  {

  label : "Italy",

  value : "ITALY"

  },

  {

  label : "Jamaica",

  value : "JAMAICA"

  },

  {

  label : "Japan",

  value : "JAPAN"

  },

  {

  label : "Jordan",

  value : "JORDAN"

  },

  {

  label : "Kazakhstan",

  value : "KAZAKHSTAN"

  },

  {

  label : "Kenya",

  value : "KENYA"

  },

  {

  label : "Kiribati",

  value : "KIRIBATI"

  },

  {

  label : "Democratic People’s Republic of Korea",

  value : "DEMOCRATIC PEOPLE'S REPUBLIC OF KOREA"

  },

  {

  label : "Republic of Korea",

  value : "REPUBLIC OF KOREA"

  },

  {

  label : "Kuwait",

  value : "KUWAIT"

  },

  {

  label : "Kyrgyzstan",

  value : "KYRGYZSTAN"

  },

  {

  label : "Lao People’s Democratic Republic",

  value : "LEO PEOPLE'S DEMOCRATIC REPLUBLIC"

  },

  {

  label : "Latvia",

  value : "LATVIA"

  },

  {

  label : "Lebanon",

  value : "LEBANON"

  },

  {

  label : "Lesotho",

  value : "LESOTHO"

  },

  {

  label : "Liberia",

  value : "LIBERIA"

  },

  {

  label : "Libyan Arab Jamahiriya",

  value : "LIBYAN ARAB JAMAHIRIYA"

  },

  {

  label : "Liechtenstein",

  value : "LIECHTENSTEIN"

  },

  {

  label : "Lithuania",

  value : "LITHUANIA"

  },

  {

  label : "Luxembourg",

  value : "LUXEMBOURG"

  },

  {

  label : "Macao",

  value : "MACAO"

  },

  {

  label : "The Former Yugoslav Republic of Macedonia",

  value : "THE FORMER YUGOSLAV REPUBLIC OF MACEDONIA"

  },

  {

  label : "Madagascar",

  value : "MADAGASCAR"

  },

  {

  label : "Malawi",

  value : "MALAWI"

  },

  {

  label : "Malaysia",

  value : "MALAYSIA"

  },

  {

  label : "Maldives",

  value : "MALDIVES"

  },

  {

  label : "Mali",

  value : "MALI"

  },

  {

  label : "Malta",

  value : "MALTA"

  },

  {

  label : "Marshall Islands",

  value : "MARSHALL ISLANDS"

  },

  {

  label : "Martinique",

  value : "MARTINIQUE"

  },

  {

  label : "Mauritania",

  value : "MAURITANIA"

  },

  {

  label : "Mauritius",

  value : "MAURITIUS"

  },

  {

  label : "Mayotte",

  value : "MAYOTTE"

  },

  {

  label : "Mexico",

  value : "MEXICO"

  },

  {

  label : "Federated States of Micronesia",

  value : "FEDERATED STATES OF MICRONESIA"

  },

  {

  label : "Republic of Moldova",

  value : "REPUBLIC OF MOLDOVA"

  },

  {

  label : "Monaco",

  value : "MONACO"

  },

  {

  label : "Mongolia",

  value : "MONGOLIA"

  },

  {

  label : "Montserrat",

  value : "MONTSERRAT"

  },

  {

  label : "Morocco",

  value : "MOROCCO"

  },

  {

  label : "Mozambique",

  value : "MOZAMBIQUE"

  },

  {

  label : "Myanmar",

  value : "MYANMAR"

  },

  {

  label : "Namibia",

  value : "NAMIBIA"

  },

  {

  label : "Nauru",

  value : "NAURU"

  },

  {

  label : "Nepal",

  value : "NEPAL"

  },

  {

  label : "Netherlands",

  value : "NETHERLANDS"

  },

  {

  label : "Netherlands Antilles",

  value : "NETHERLANDS ANTILLES"

  },

  {

  label : "New Caledonia",

  value : "NEW CALENDONIA"

  },

  {

  label : "New Zealand",

  value : "NEW ZEALAND"

  },

  {

  label : "Nicaragua",

  value : "NICARAGUA"

  },

  {

  label : "Niger",

  value : "NIGER"

  },

  {

  label : "Nigeria",

  value : "NIGERIA"

  },

  {

  label : "Niue",

  value : "NIUE"

  },

  {

  label : "Norfolk Island",

  value : "NORFOLK ISLAND"

  },

  {

  label : "Northern Mariana Islands",

  value : "NORTHERN MARIANA ISLANDS"

  },

  {

  label : "Norway",

  value : "NORWAY"

  },

  {

  label : "Oman",

  value : "OMAN"

  },

  {

  label : "Pakistan",

  value : "PAKISTAN"

  },

  {

  label : "Palau",

  value : "PALAU"

  },

  {

  label : "Occupied Palestinian Territory",

  value : "OCCUPIED PALESTINIAN TERRITORY"

  },

  {

  label : "Panama",

  value : "PANAMA"

  },

  {

  label : "Papua New Guinea",

  value : "PAPUA NEW GUINEA"

  },

  {

  label : "Paraguay",

  value : "PARAGUAY"

  },

  {

  label : "Peru",

  value : "PERU"

  },

  {

  label : "Philippines",

  value : "PHILIPPINES"

  },

  {

  label : "Pitcairn",

  value : "PITCAIRN"

  },

  {

  label : "Poland",

  value : "POLAND"

  },

  {

  label : "Portugal",

  value : "PORTUGAL"

  },

  {

  label : "Puerto Rico",

  value : "PUERTO RICO"

  },

  {

  label : "Qatar",

  value : "QATAR"

  },

  {

  label : "Reunion",

  value : "REUNION"

  },

  {

  label : "Romania",

  value : "ROMANIA"

  },

  {

  label : "Russian Federation",

  value : "RUSSIAN FEDERATION"

  },

  {

  label : "Rwanda",

  value : "RWANDA"

  },

  {

  label : "Saint Helena",

  value : "SAINT HELENA"

  },

  {

  label : "Saint Kitts and Nevis",

  value : "SAINT KITTS AND NEVIS"

  },

  {

  label : "Saint Lucia",

  value : "SAINT LUCIA"

  },

  {

  label : "Saint Pierre and Miquelon",

  value : "SAINT PIERRE AND MIQUELON"

  },

  {

  label : "Saint Vincent and The Grenadines",

  value : "SAINT VINCENT AND THE GRENADINES"

  },

  {

  label : "Samoa",

  value : "SAMOA"

  },

  {

  label : "San Marino",

  value : "SAN MARINO"

  },

  {

  label : "Sao Tome and Principe",

  value : "SAO TOME AND PRINCIPE"

  },

  {

  label : "Saudi Arabia",

  value : "SAUDI ARABIA"

  },

  {

  label : "Senegal",

  value : "SENEGAL"

  },

  {

  label : "Serbia and Montenegro",

  value : "SERBIA AND MONTENEGRO"

  },

  {

  label : "Seychelles",

  value : "SEYCHELLES"

  },

  {

  label : "Sierra Leone",

  value : "SIERRA LEONE"

  },

  {

  label : "Singapore",

  value : "SINGAPORE"

  },

  {

  label : "Slovakia",

  value : "SLOVAKIA"

  },

  {

  label : "Slovenia",

  value : "SLOVIENIA"

  },

  {

  label : "Solomon Islands",

  value : "SOLOMON ISLANDS"

  },

  {

  label : "Somalia",

  value : "SOMALIA"

  },

  {

  label : "South Africa",

  value : "SOUTH AFRICA"

  },

  {

  label : "South Sudan",

  value : "SOUTH SUDAN"

  },

  {

  label : "South Georgia and The South Sandwich Islands",

  value : "SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS"

  },

  {

  label : "Spain",

  value : "SPAIN"

  },

  {

  label : "Sri Lanka",

  value : "SRI LANKA"

  },

  {

  label : "Sudan",

  value : "SUDAN"

  },

  {

  label : "Suriname",

  value : "SURINAME"

  },

  {

  label : "Svalbard and Jan Mayen",

  value : "SVALBARD AND JAN MAYEN"

  },

  {

  label : "Swaziland",

  value : "SWAZILAND"

  },

  {

  label : "Sweden",

  value : "SWEDEN"

  },

  {

  label : "Switzerland",

  value : "SWITZERLAND"

  },

  {

  label : "Syrian Arab Republic",

  value : "SYRIAN ARAB REPUBLIC"

  },

  {

  label : "Taiwan",

  value : "TAIWAN"

  },

  {

  label : "Tajikistan",

  value : "TAJIKISTAN"

  },

  {

  label : "United Republic of Tanzania",

  value : "UNITED REPUBLIC OF TANZANIA"

  },

  {

  label : "Thailand",

  value : "THAILAND"

  },

  {

  label : "Timor-Leste",

  value : "TIMOR-LESTE"

  },

  {

  label : "Togo",

  value : "TOGO"

  },

  {

  label : "Tokelau",

  value : "TOKELAU"

  },

  {

  label : "Tonga",

  value : "TONGA"

  },

  {

  label : "Trinidad and Tobago",

  value : "TRINIDAD AND TOBAGO"

  },

  {

  label : "Tunisia",

  value : "TUNISIA"

  },

  {

  label : "Turkey",

  value : "TURKEY"

  },

  {

  label : "Turkmenistan",

  value : "TURKMENISTAN"

  },

  {

  label : "Turks and Caicos Islands",

  value : "TURKS AND CAICOS ISLANDS"

  },

  {

  label : "Tuvalu",

  value : "TUVALU"

  },

  {

  label : "Uganda",

  value : "UGANDA"

  },

  {

  label : "Ukraine",

  value : "UKRAINE"

  },

  {

  label : "United Arab Emirates",

  value : "UNITED ARAB EMIRATES"

  },

  {

  label : "United Kingdom",

  value : "UNITED KINGDOM"

  },

  {

  label : "United States",

  value : "UNITED STATES"

  },

  {

  label : "United States Minor Outlying Islands",

  value : "UNITED STATES MINOR OUTLYING ISLANDS"

  }, {

  label : "Uruguay",

  value : "URUGUAY"

  }, {

  label : "Uzbekistan",

  value : "UZBEKISTAN"

  }, {

  label : "Vanuatu",

  value : "VANUATU"

  }, {

  label : "Venezuela",

  value : "VENEZUELA"

  }, {

  label : "Viet Nam",

  value : "VIET NAM"

  }, {

  label : "Virgin Islands, British",

  value : "VIRGIN ISLANDS, BRITISH"

  }, {

  label : "Virgin Islands, U.S.",

  value : "VIRGIN ISLANDS, U.S"

  }, {

  label : "Wallis and Futuna",

  value : "WALLIS AND FUTUNA"

  }, {

  label : "Western Sahara",

  value : "WESTER SAHARA"

  }, {

  label : "Yemen",

  value : "YEMEN"

  }, {

  label : "Zambia",

  value : "ZAMBIA"

  }, {

  label : "Zimbabwe",

  value : "ZIMBABWE"

  } ]

  }

  }

  }, {

  name : "alfresco/forms/controls/TextArea",

  config : {

  fieldId : "reason",

  label : "Description",

  description : "Describe your need",

  name : "reason",

  requirementConfig : {

  initialValue : true

  }

  }

  } ],

  okButtonPublishGlobal : true,

  okButtonPublishPayload : {

  url : "/hopenshare/student/apologycourse.json",

  },

  }

};

</code>

the form I want it in this format if it's possible:
<code>

{

     "studentName": "Testing form",

     "studentCardNo": 103255,

     "studentPhoneNo":0000000000,

     "studentCollege": "Arts",

     "email":"test@gmail.com",

     "date": "10/20/2006 12:00",

     "country": "Germany",

     "reason": 321321

}

</code>

1 ACCEPTED ANSWER

kaynezhang
World-Class Innovator
World-Class Innovator

Sorry I'm not clear about what you want to ask.

View answer in original post

7 REPLIES 7

kaynezhang
World-Class Innovator
World-Class Innovator

Sorry I'm not clear about what you want to ask.

hdalang
Champ in-the-making
Champ in-the-making

Hi, thanks for your reply, I'm actually sending a form to webscript to a webscript which I designed before inside alfresco:the form I used to work with some applications like postman, google advanced rest client, as shown like this:

url "/hopenshare/student/apologycourse.json"

the form I used to work with some applications like postman, google advanced rest client, as shown like this:

     "studentName": "Testing form",

     "studentCardNo": 103255,

     "studentPhoneNo":0000000000,

     "studentCollege": "Arts",

     "email":"test@gmail.com",

     "date": "10/20/2006 12:00",

     "country": "Germany",

     "reason": 321321

so the problem is that I'm trying now to do a form inside alfresco for this purpose if you getting me, I want to send the data to alfresco using aikau in this format, and I have placed in the previous post what my code looks like, so If you can tell me how to make the code after filling the form send in json format?

<code>

package com.std.webscript;

import java.io.Serializable;

import java.util.HashMap;

import java.util.Map;

import org.alfresco.service.cmr.workflow.WorkflowDefinition;

import org.alfresco.service.cmr.workflow.WorkflowPath;

import org.alfresco.service.cmr.workflow.WorkflowService;

import org.alfresco.service.namespace.QName;

import org.apache.chemistry.opencmis.commons.impl.json.parser.JSONParseException;

import org.json.JSONException;

import org.json.JSONObject;

import org.springframework.extensions.webscripts.Cache;

import org.springframework.extensions.webscripts.DeclarativeWebScript;

import org.springframework.extensions.webscripts.Status;

import org.springframework.extensions.webscripts.WebScriptRequest;

import com.hopenshare.std.constant.MyModel;

public class StdApologyCourse extends DeclarativeWebScript {

  public static final String TIME_SPLITER = ";";

  private WorkflowService workflowService;

  public void setWorkflowService(WorkflowService workflowService) {

  this.workflowService = workflowService;

  }

  protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {

  // String[] params = req.getParameterNames();

  Map<QName, Serializable> map = new HashMap<QName, Serializable>();

  /*

  * for (String param : params) { QName key = QName.createQName(param);

  * map.put(key, req.getParameter(param)); }

  */

  System.out.println("StdApologyCourse java class");

  String studentName = req.getParameter("studentName");

  String studentCardNo = req.getParameter("studentCardNo");

  String studentPhoneNo = req.getParameter("studentPhoneNo");

  String studentCollege = req.getParameter("studentCollege");

  String email = req.getParameter("email");

  String date = req.getParameter("date");

  String country = req.getParameter("country");

  String reason = req.getParameter("reason");

  JSONObject reqJsonObject = (JSONObject) req.parseContent();

  try {

  studentName = reqJsonObject.getString("studentName");

  studentCardNo = reqJsonObject.getString("studentCardNo");

  studentPhoneNo = reqJsonObject.getString("studentPhoneNo");

  studentCollege = reqJsonObject.getString("studentCollege");

  email = reqJsonObject.getString("email");

  date = reqJsonObject.getString("date");

  country = reqJsonObject.getString("country");

  reason = reqJsonObject.getString("reason");

  } catch (JSONException jspe) {

  jspe.printStackTrace();

  }

  System.out.println(studentName);

  System.out.println(studentCardNo);

  System.out.println(studentPhoneNo);

  System.out.println(studentCollege);

  System.out.println(email);

  System.out.println(date);

  System.out.println(country);

  System.out.println(reason);

  map.put(MyModel.PROPERTY_APOLOGIZE_FROM_COURSE_STUDENT_NAME, studentName);

  map.put(MyModel.PROPERTY_APOLOGIZE_FROM_COURSE_STUDENT_CARD_NO, studentCardNo);

  map.put(MyModel.PROPERTY_APOLOGIZE_FROM_COURSE_STUDENT_PHONE_NO, studentPhoneNo);

  map.put(MyModel.PROPERTY_APOLOGIZE_FROM_COURSE_STUDENT_COLLEGE, studentCollege);

  map.put(MyModel.PROPERTY_APOLOGIZE_FROM_COURSE_STUDENT_EMAIL, email);

  map.put(MyModel.PROPERTY_APOLOGIZE_FROM_COURSE_STUDENT_DATE, date);

  map.put(MyModel.PROPERTY_APOLOGIZE_FROM_COURSE_STUDENT_COUNTRY, country);

  map.put(MyModel.PROPERTY_APOLOGIZE_FROM_COURSE_STUDENT_REASON, reason);

  WorkflowDefinition wfDef = workflowService.getDefinitionByName("activiti$stdApologyCourse");

  WorkflowPath wfPath = workflowService.startWorkflow(wfDef.getId(), map);

  final Map<String, Object> model = new HashMap<String, Object>();

  model.put("stdApologyCourse", wfPath.getInstance().getId());

  model.put("studentName", studentName);

  model.put("studentCardNo", studentCardNo);

  model.put("studentPhoneNo", studentPhoneNo);

  model.put("studentCollege", studentCollege);

  model.put("email", email);

  model.put("date", date);

  model.put("country", country);

  model.put("reason", reason);

  return model;

  }

}

</code>

kaynezhang
World-Class Innovator
World-Class Innovator

You mean you have developed an alfresco webscript api which has an JSON request format parameter,and you have already tested using postman,and now you want to customize share ?

If yes you can refer to https://github.com/Alfresco/Aikau/blob/master/tutorial/chapters/Tutorial7.md

and https://github.com/Alfresco/Aikau/blob/master/tutorial/chapters/Tutorial16.md

hdalang
Champ in-the-making
Champ in-the-making

ok, I have two thing I want to read the form data by name and I have defined this service and I tried to send data that brought from the form as shown below, but only the alert worked:

define([ "dojo/_base/declare", "alfresco/core/Core", "dojo/_base/lang",

  "alfresco/core/CoreXhr", "service/constants/Default" ], function(

  declare, Core, lang, CoreXhr, AlfConstants) {

  return declare([ Core, CoreXhr ], {

  constructor : function tutorial_UserAndGroupService__constructor(args) {

  lang.mixin(this, args);

  this.alfSubscribe("STUDENT_SEND_DATA", lang.hitch(this,

  this.sendData));

  },

  sendData : function student_send__data(payload) {

  alert(payload.student-name);

  this.serviceXhr({

  url : "/hopenshare/student/apologycourse.json",

  method : "POST",

  data : {

  "studentName" : "Testing form", //Sample data

  "studentCardNo" : 103255, // Sample data

  "studentPhoneNo" : 0000000000, // Sample data

  "studentCollege" : "Arts", // Sample data

  "email" : "test@gmail.com", // Sample data

  "date" : "10/20/2006 12:00", // Sample data

  "country" : "Germany", // Sample data

  "reason" : 321321 // Sample data

  },

  successCallback : this.onSuccess,

  callbackScope : this

  });

  },

  onSuccess : function success() {

  alert('message is sent successfully');

  }

  });

});

hdalang
Champ in-the-making
Champ in-the-making

The new code is shown here:

{

  name : "alfresco/forms/Form",

  config : {

  okButtonPublishTopic : "STUDENT_SEND_DATA",

  okButtonLabel : "Submit",

  showValidationErrorsImmediately : false,

  widgets : [

  {

  name : "alfresco/forms/controls/TextBox",

  config : {

  fieldId : "student-name",

  label : "Student Name",

  placeHolder : "Enter your name",

  name : "student-name",

  requirementConfig : {

  initialValue : true

  }

  }

  },

  {

  name : "alfresco/forms/controls/TextBox",

  config : {

  fieldId : "student-card-no",

  label : "Student Card Number",

  placeHolder : "Enter your card number",

  name : "student-card-no",

  type : "number",

  validationConfig : [ {

  "validation" : "regex",

  "regex" : "^[0-9]+$",

  "errorMessage" : "Numbers only"

  } ],

  requirementConfig : {

  initialValue : true,

  rules : [ {

  targetId : "SHOW",

  is : [ true ]

  } ]

  }

  }

  },

  {

  name : "alfresco/forms/controls/Select",

  config : {

  fieldId : "student-college",

  label : "Student College",

  name : "student-college",

  optionsConfig : {

  fixed : [ {

  label : "Faculty of Sharia",

  value : "FACULTY OF SHARIA"

  }, {

  label : "Faculty of Education",

  value : "FACULTY OF EDUCATION"

  }, {

  label : "Faculty of Arts",

  value : "FACULTY OF ARTS"

  }, {

  label : "Faculty of  Ecnomic",

  value : "FACULTY OF ECONOMIC"

  }, {

  label : "Faculty of Sciences",

  value : "FACULTY OF SCIENCES"

  }, {

  label : "Faculty of Computer",

  value : "FACULTY OF COMPUTER"

  }, {

  label : "Faculty of Engineering",

  value : "FACULTY OF ENGINEERING"

  }, {

  label : "Faculty of Medicine",

  value : "FACULTY OF MEDICINE"

  }, {

  label : "Faculty of Pharmcy",

  value : "FACULTY OF PHARMCY"

  }, {

  label : "Faculty of  Nursing",

  value : "FACULTY OF NURSING"

  }, {

  label : "Faculty of Oral",

  value : "FACULTY OF ORAL"

  }, {

  label : "Faculty of Metals",

  value : "FACULTY OF METALS"

  }, {

  label : "Faculty of Communications",

  value : "FACULTY OF COMMUNICATIONS"

  }, {

  label : "Faculty of  Laboratory",

  value : "FACULTY OF LABORATORY"

  }, {

  label : "Faculty of Islamicstudies",

  value : "FACULTY OF ISLAMICSTUDIES"

  }, {

  label : "Faculty of Agriculture",

  value : "FACULTY OF AGRICULTURE"

  } ]

  }

  }

  },

  {

  name : "alfresco/forms/controls/TextBox",

  config : {

  fieldId : "student-phone-no",

  label : "Student Phone Number",

  placeHolder : "Enter your phone number",

  name : "student-phone-no",

  requirementConfig : {

  initialValue : true

  },

  validationConfig : [ {

  "validation" : "regex",

  "regex" : "^[0-9]+$",

  "errorMessage" : "Numbers only"

  } ]

  }

  },

  {

  name : "alfresco/forms/controls/TextBox",

  config : {

  fieldId : "email",

  label : "Email",

  placeHolder : "Enter your email",

  name : "email",

  validationConfig : [ {

  validation : "regex",

  regex : "^([0-9a-zA-Z]([-.w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-w]*[0-9a-zA-Z].)+[a-zA-Z]{2,9})$",

  errorMessage : "Valid E-mail Address Required"

  } ],

  requirementConfig : {

  initialValue : true

  }

  }

  },

  {

  name : "alfresco/forms/controls/Select",

  config : {

  fieldId : "COUNTRY",

  label : "Country",

  description : "Select your Country",

  name : "country",

  optionsConfig : {

  fixed : [

  {

  label : "Afghanistan",

  value : "AFGHANISTAN"

  },

  {

  label : "Albania",

  value : "ALBANIA"

  },

  {

  label : "American Samoa",

  value : "AMERICAN SAMOA"

  },

  {

  label : "Andorra",

  value : "ANDORRA"

  },

  {

  label : "Angola",

  value : "ANGOLA"

  },

  {

  label : "Anguilla",

  value : "ANGUILLA"

  },

  {

  label : "Antarctica",

  value : "ANTARCTICA"

  },

  {

  label : "Antigua and Barbuda",

  value : "ANTIGUA AND BARBUDA"

  },

  {

  label : "Argentina",

  value : "ARGENTINA"

  },

  {

  label : "Armenia",

  value : "ARMENIA"

  },

  {

  label : "Aruba",

  value : "ARUBA"

  },

  {

  label : "Australia",

  value : "AUSTRALIA"

  },

  {

  label : "Austria",

  value : "AUSTRIA"

  },

  {

  label : "Azerbaijan",

  value : "AZERBAIJAN"

  },

  {

  label : "Bahamas",

  value : "BAHAMAS"

  },

  {

  label : "Bahrain",

  value : "BAHRAIN"

  },

  {

  label : "Bangladesh",

  value : "BANGLADESH"

  },

  {

  label : "Barbados",

  value : "BARBADOS"

  },

  {

  label : "Belarus",

  value : "BELARUS"

  },

  {

  label : "Belgium",

  value : "BELGIUM"

  },

  {

  label : "Belize",

  value : "BELIZE"

  },

  {

  label : "Benin",

  value : "BENIN"

  },

  {

  label : "Bermuda",

  value : "BERMUDA"

  },

  {

  label : "Bhutan",

  value : "BHUTAN"

  },

  {

  label : "Bolivia",

  value : "BOLIVIA"

  },

  {

  label : "Bosnia and Herzegovina",

  value : "BOSNIA AND HERZEGOVINA"

  },

  {

  label : "Botswana",

  value : "BOTSWANA"

  },

  {

  label : "Bouvet Island",

  value : "BOUVET ISLAND"

  },

  {

  label : "Brazil",

  value : "BRAZIL"

  },

  {

  label : "British Indian Ocean Territory",

  value : "BRITISH INDIAN OCEAN TERRITORY"

  },

  {

  label : "Brunei Darussalam",

  value : "BRUNEI DARUSSALAM"

  },

  {

  label : "Bulgaria",

  value : "BULGARIA"

  },

  {

  label : "Burkina Faso",

  value : "BURKINA FASO"

  },

  {

  label : "Burundi",

  value : "BURUNDI"

  },

  {

  label : "Cambodia",

  value : "CAMBODIA"

  },

  {

  label : "Canada",

  value : "CANADA"

  },

  {

  label : "Cape Verde",

  value : "CAPE VERDE"

  },

  {

  label : "Cayman Islands",

  value : "CAYMAN ISLANDS"

  },

  {

  label : "Central African Republic",

  value : "CENTRAL AFRICAN REPUBLIC"

  },

  {

  label : "Chad",

  value : "CHAD"

  },

  {

  label : "Chile",

  value : "CHILI"

  },

  {

  label : "China",

  value : "CHINA"

  },

  {

  label : "Christmas Island",

  value : "CHRISTMAS ISLAND"

  },

  {

  label : "Cocos (Keeling) Islands",

  value : "COCOS (KEELING) ISLANDS"

  },

  {

  label : "Colombia",

  value : "COLOMBIA"

  },

  {

  label : "Comoros",

  value : "COMOROS"

  },

  {

  label : "Congo",

  value : "CONGO"

  },

  {

  label : "The Democratic Republic of The Congo",

  value : "THE DEMOCRATIC REPUBLIC OF THE CONGO"

  },

  {

  label : "Cook Islands",

  value : "COOK ISLANDS"

  },

  {

  label : "Costa Rica",

  value : "COSTA RICA"

  },

  {

  label : "Cote D’ivoire",

  value : "COTE D’IVOIRE"

  },

  {

  label : "Croatia",

  value : "CROATIA"

  },

  {

  label : "Cuba",

  value : "CUBA"

  },

  {

  label : "Cyprus",

  value : "CYPRUS"

  },

  {

  label : "Czech Republic",

  value : "CZECH REPUBLIC"

  },

  {

  label : "Denmark",

  value : "DENMARK"

  },

  {

  label : "Djibouti",

  value : "DJIBOUTI"

  },

  {

  label : "Dominica",

  value : "DOMINICA"

  },

  {

  label : "Dominican Republic",

  value : "COOK ISLANDS"

  },

  {

  label : "Ecuador",

  value : "ECUADOR"

  },

  {

  label : "Egypt",

  value : "EGYPT"

  },

  {

  label : "El Salvador",

  value : "EL SALVADOR"

  },

  {

  label : "Equatorial Guinea",

  value : "EQUATORIAL GUINEA"

  },

  {

  label : "Eritrea",

  value : "ERITREA"

  },

  {

  label : "Estonia",

  value : "ESTONIA"

  },

  {

  label : "Ethiopia",

  value : "ETHIOPIA"

  },

  {

  label : "Falkland Islands (Malvinas)",

  value : "FALKLAND ISLANDS (MALVINAS)"

  },

  {

  label : "Faroe Islands",

  value : "FOROE ISLANDS"

  },

  {

  label : "Fiji",

  value : "Fiji"

  },

  {

  label : "Finland",

  value : "FINLAND"

  },

  {

  label : "French Guiana",

  value : "FRENCH GUIANA"

  },

  {

  label : "French Polynesia",

  value : "FRENCH POLYNESIA"

  },

  {

  label : "French Southern Territories",

  value : "FRENCH SOUTHERN TERRITORIES"

  },

  {

  label : "Gabon",

  value : "GABON"

  },

  {

  label : "Gambia",

  value : "GAMBIA"

  },

  {

  label : "Georgia",

  value : "GEORGIA"

  },

  {

  label : "Estonia",

  value : "ESTONIA"

  },

  {

  label : "Germany",

  value : "GERMANY"

  },

  {

  label : "Ghana",

  value : "GHANA"

  },

  {

  label : "Gibraltar",

  value : "GIBRALTAR"

  },

  {

  label : "Greece",

  value : "GREECE"

  },

  {

  label : "Greenland",

  value : "GREENLAND"

  },

  {

  label : "Grenada",

  value : "GRENADA"

  },

  {

  label : "Guadeloupe",

  value : "GUADELOUPE"

  },

  {

  label : "Guam",

  value : "GUAM"

  },

  {

  label : "Guatemala",

  value : "GUATEMALA"

  },

  {

  label : "Guinea",

  value : "GUINEA"

  },

  {

  label : "Guinea bissau",

  value : "GUINEA BISSAU"

  },

  {

  label : "Guyana",

  value : "GUYANA"

  },

  {

  label : "Haiti",

  value : "HAITI"

  },

  {

  label : "Heard Island and Mcdonald Islands",

  value : "HEARD ISLAND AND MCDONALD ISLANDS"

  },

  {

  label : "Holy See (Vatican City State)",

  value : "HOLY SEE(VATICAN CITY STATE)"

  },

  {

  label : "Honduras",

  value : "HONDURAS"

  },

  {

  label : "Hong Kong",

  value : "HONG KONG"

  },

  {

  label : "Hungary",

  value : "HUNGARY"

  },

  {

  label : "Iceland",

  value : "ICELAND"

  },

  {

  label : "India",

  value : "INDIA"

  },

  {

  label : "Indonesia",

  value : "INDONESIA"

  },

  {

  label : "Islamic Republic of Iran",

  value : "ISLAMIC REPUBLIC OF IRAN"

  },

  {

  label : "Iraq",

  value : "IRAQ"

  },

  {

  label : "Ireland",

  value : "IRELAND"

  },

  {

  label : "Israel",

  value : "ISRAEL"

  },

  {

  label : "Italy",

  value : "ITALY"

  },

  {

  label : "Jamaica",

  value : "JAMAICA"

  },

  {

  label : "Japan",

  value : "JAPAN"

  },

  {

  label : "Jordan",

  value : "JORDAN"

  },

  {

  label : "Kazakhstan",

  value : "KAZAKHSTAN"

  },

  {

  label : "Kenya",

  value : "KENYA"

  },

  {

  label : "Kiribati",

  value : "KIRIBATI"

  },

  {

  label : "Democratic People’s Republic of Korea",

  value : "DEMOCRATIC PEOPLE'S REPUBLIC OF KOREA"

  },

  {

  label : "Republic of Korea",

  value : "REPUBLIC OF KOREA"

  },

  {

  label : "Kuwait",

  value : "KUWAIT"

  },

  {

  label : "Kyrgyzstan",

  value : "KYRGYZSTAN"

  },

  {

  label : "Lao People’s Democratic Republic",

  value : "LEO PEOPLE'S DEMOCRATIC REPLUBLIC"

  },

  {

  label : "Latvia",

  value : "LATVIA"

  },

  {

  label : "Lebanon",

  value : "LEBANON"

  },

  {

  label : "Lesotho",

  value : "LESOTHO"

  },

  {

  label : "Liberia",

  value : "LIBERIA"

  },

  {

  label : "Libyan Arab Jamahiriya",

  value : "LIBYAN ARAB JAMAHIRIYA"

  },

  {

  label : "Liechtenstein",

  value : "LIECHTENSTEIN"

  },

  {

  label : "Lithuania",

  value : "LITHUANIA"

  },

  {

  label : "Luxembourg",

  value : "LUXEMBOURG"

  },

  {

  label : "Macao",

  value : "MACAO"

  },

  {

  label : "The Former Yugoslav Republic of Macedonia",

  value : "THE FORMER YUGOSLAV REPUBLIC OF MACEDONIA"

  },

  {

  label : "Madagascar",

  value : "MADAGASCAR"

  },

  {

  label : "Malawi",

  value : "MALAWI"

  },

  {

  label : "Malaysia",

  value : "MALAYSIA"

  },

  {

  label : "Maldives",

  value : "MALDIVES"

  },

  {

  label : "Mali",

  value : "MALI"

  },

  {

  label : "Malta",

  value : "MALTA"

  },

  {

  label : "Marshall Islands",

  value : "MARSHALL ISLANDS"

  },

  {

  label : "Martinique",

  value : "MARTINIQUE"

  },

  {

  label : "Mauritania",

  value : "MAURITANIA"

  },

  {

  label : "Mauritius",

  value : "MAURITIUS"

  },

  {

  label : "Mayotte",

  value : "MAYOTTE"

  },

  {

  label : "Mexico",

  value : "MEXICO"

  },

  {

  label : "Federated States of Micronesia",

  value : "FEDERATED STATES OF MICRONESIA"

  },

  {

  label : "Republic of Moldova",

  value : "REPUBLIC OF MOLDOVA"

  },

  {

  label : "Monaco",

  value : "MONACO"

  },

  {

  label : "Mongolia",

  value : "MONGOLIA"

  },

  {

  label : "Montserrat",

  value : "MONTSERRAT"

  },

  {

  label : "Morocco",

  value : "MOROCCO"

  },

  {

  label : "Mozambique",

  value : "MOZAMBIQUE"

  },

  {

  label : "Myanmar",

  value : "MYANMAR"

  },

  {

  label : "Namibia",

  value : "NAMIBIA"

  },

  {

  label : "Nauru",

  value : "NAURU"

  },

  {

  label : "Nepal",

  value : "NEPAL"

  },

  {

  label : "Netherlands",

  value : "NETHERLANDS"

  },

  {

  label : "Netherlands Antilles",

  value : "NETHERLANDS ANTILLES"

  },

  {

  label : "New Caledonia",

  value : "NEW CALENDONIA"

  },

  {

  label : "New Zealand",

  value : "NEW ZEALAND"

  },

  {

  label : "Nicaragua",

  value : "NICARAGUA"

  },

  {

  label : "Niger",

  value : "NIGER"

  },

  {

  label : "Nigeria",

  value : "NIGERIA"

  },

  {

  label : "Niue",

  value : "NIUE"

  },

  {

  label : "Norfolk Island",

  value : "NORFOLK ISLAND"

  },

  {

  label : "Northern Mariana Islands",

  value : "NORTHERN MARIANA ISLANDS"

  },

  {

  label : "Norway",

  value : "NORWAY"

  },

  {

  label : "Oman",

  value : "OMAN"

  },

  {

  label : "Pakistan",

  value : "PAKISTAN"

  },

  {

  label : "Palau",

  value : "PALAU"

  },

  {

  label : "Occupied Palestinian Territory",

  value : "OCCUPIED PALESTINIAN TERRITORY"

  },

  {

  label : "Panama",

  value : "PANAMA"

  },

  {

  label : "Papua New Guinea",

  value : "PAPUA NEW GUINEA"

  },

  {

  label : "Paraguay",

  value : "PARAGUAY"

  },

  {

  label : "Peru",

  value : "PERU"

  },

  {

  label : "Philippines",

  value : "PHILIPPINES"

  },

  {

  label : "Pitcairn",

  value : "PITCAIRN"

  },

  {

  label : "Poland",

  value : "POLAND"

  },

  {

  label : "Portugal",

  value : "PORTUGAL"

  },

  {

  label : "Puerto Rico",

  value : "PUERTO RICO"

  },

  {

  label : "Qatar",

  value : "QATAR"

  },

  {

  label : "Reunion",

  value : "REUNION"

  },

  {

  label : "Romania",

  value : "ROMANIA"

  },

  {

  label : "Russian Federation",

  value : "RUSSIAN FEDERATION"

  },

  {

  label : "Rwanda",

  value : "RWANDA"

  },

  {

  label : "Saint Helena",

  value : "SAINT HELENA"

  },

  {

  label : "Saint Kitts and Nevis",

  value : "SAINT KITTS AND NEVIS"

  },

  {

  label : "Saint Lucia",

  value : "SAINT LUCIA"

  },

  {

  label : "Saint Pierre and Miquelon",

  value : "SAINT PIERRE AND MIQUELON"

  },

  {

  label : "Saint Vincent and The Grenadines",

  value : "SAINT VINCENT AND THE GRENADINES"

  },

  {

  label : "Samoa",

  value : "SAMOA"

  },

  {

  label : "San Marino",

  value : "SAN MARINO"

  },

  {

  label : "Sao Tome and Principe",

  value : "SAO TOME AND PRINCIPE"

  },

  {

  label : "Saudi Arabia",

  value : "SAUDI ARABIA"

  },

  {

  label : "Senegal",

  value : "SENEGAL"

  },

  {

  label : "Serbia and Montenegro",

  value : "SERBIA AND MONTENEGRO"

  },

  {

  label : "Seychelles",

  value : "SEYCHELLES"

  },

  {

  label : "Sierra Leone",

  value : "SIERRA LEONE"

  },

  {

  label : "Singapore",

  value : "SINGAPORE"

  },

  {

  label : "Slovakia",

  value : "SLOVAKIA"

  },

  {

  label : "Slovenia",

  value : "SLOVIENIA"

  },

  {

  label : "Solomon Islands",

  value : "SOLOMON ISLANDS"

  },

  {

  label : "Somalia",

  value : "SOMALIA"

  },

  {

  label : "South Africa",

  value : "SOUTH AFRICA"

  },

  {

  label : "South Sudan",

  value : "SOUTH SUDAN"

  },

  {

  label : "South Georgia and The South Sandwich Islands",

  value : "SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS"

  },

  {

  label : "Spain",

  value : "SPAIN"

  },

  {

  label : "Sri Lanka",

  value : "SRI LANKA"

  },

  {

  label : "Sudan",

  value : "SUDAN"

  },

  {

  label : "Suriname",

  value : "SURINAME"

  },

  {

  label : "Svalbard and Jan Mayen",

  value : "SVALBARD AND JAN MAYEN"

  },

  {

  label : "Swaziland",

  value : "SWAZILAND"

  },

  {

  label : "Sweden",

  value : "SWEDEN"

  },

  {

  label : "Switzerland",

  value : "SWITZERLAND"

  },

  {

  label : "Syrian Arab Republic",

  value : "SYRIAN ARAB REPUBLIC"

  },

  {

  label : "Taiwan",

  value : "TAIWAN"

  },

  {

  label : "Tajikistan",

  value : "TAJIKISTAN"

  },

  {

  label : "United Republic of Tanzania",

  value : "UNITED REPUBLIC OF TANZANIA"

  },

  {

  label : "Thailand",

  value : "THAILAND"

  },

  {

  label : "Timor-Leste",

  value : "TIMOR-LESTE"

  },

  {

  label : "Togo",

  value : "TOGO"

  },

  {

  label : "Tokelau",

  value : "TOKELAU"

  },

  {

  label : "Tonga",

  value : "TONGA"

  },

  {

  label : "Trinidad and Tobago",

  value : "TRINIDAD AND TOBAGO"

  },

  {

  label : "Tunisia",

  value : "TUNISIA"

  },

  {

  label : "Turkey",

  value : "TURKEY"

  },

  {

  label : "Turkmenistan",

  value : "TURKMENISTAN"

  },

  {

  label : "Turks and Caicos Islands",

  value : "TURKS AND CAICOS ISLANDS"

  },

  {

  label : "Tuvalu",

  value : "TUVALU"

  },

  {

  label : "Uganda",

  value : "UGANDA"

  },

  {

  label : "Ukraine",

  value : "UKRAINE"

  },

  {

  label : "United Arab Emirates",

  value : "UNITED ARAB EMIRATES"

  },

  {

  label : "United Kingdom",

  value : "UNITED KINGDOM"

  },

  {

  label : "United States",

  value : "UNITED STATES"

  },

  {

  label : "United States Minor Outlying Islands",

  value : "UNITED STATES MINOR OUTLYING ISLANDS"

  }, {

  label : "Uruguay",

  value : "URUGUAY"

  }, {

  label : "Uzbekistan",

  value : "UZBEKISTAN"

  }, {

  label : "Vanuatu",

  value : "VANUATU"

  }, {

  label : "Venezuela",

  value : "VENEZUELA"

  }, {

  label : "Viet Nam",

  value : "VIET NAM"

  }, {

  label : "Virgin Islands, British",

  value : "VIRGIN ISLANDS, BRITISH"

  }, {

  label : "Virgin Islands, U.S.",

  value : "VIRGIN ISLANDS, U.S"

  }, {

  label : "Wallis and Futuna",

  value : "WALLIS AND FUTUNA"

  }, {

  label : "Western Sahara",

  value : "WESTER SAHARA"

  }, {

  label : "Yemen",

  value : "YEMEN"

  }, {

  label : "Zambia",

  value : "ZAMBIA"

  }, {

  label : "Zimbabwe",

  value : "ZIMBABWE"

  } ]

  }

  }

  }, {

  name : "alfresco/forms/controls/TextArea",

  config : {

  fieldId : "reason",

  label : "Description",

  description : "Describe your need",

  name : "reason",

  requirementConfig : {

  initialValue : true

  }

  }

  } ],

  okButtonPublishGlobal : true

  }

};

hdalang
Champ in-the-making
Champ in-the-making

Just let me describe my problems in few lines here:
1- I have created a form as shown in previous code, I want to send this form in json format to specific webscript, my problem now is how to do that?
2- What I have done until now is that I have created a new service and I have placed it in services at model.json place, and I did change the

okButtonPublishTopic : "STUDENT_SEND_DATA"

I'm not sure if it's right or wrong.

3- I have added alert  at the beginning of services to see that the service is working or not and I saw it's working but I cannot read or send form data to required webscript, and I have placed the code for this service.

4- How to read form data in alfresco?

ddraper
World-Class Innovator
World-Class Innovator

The data that the Aikau form will be sending is always in JSON. The "name" and "value" attributes of each field in the form will create a key/value pair for data in the JSON submission. If you want to use the CrudService then you can configure the okButtonPublishTopic to be "ALF_CRUD_CREATE" for an HTTP POST - however you will need to ensure that the payload published by the form also includes the "url" that you want to publish to. All of this is covered in the Aikau tutorial on GitHub which I suggest you work through if you haven't already.

It could be that the issue you're having is in how to actually read the data being POST in a custom WebScript ?

If this is the case then you need to make sure that your WebScript files are correct, in that you have for example "my-webscript.post.desc.xml" (for the descriptor), "my-webscript.post.js" (for the controller), "my-webscript.post.json.ftl" (for the template) and to make sure that your WebScript descriptor includes:

<format default="json">argument</format>

...to indicate that JSON is the default format. You can then access the JSON data via the "json" attribute in your WebScript controller.