Skip to content

Instantly share code, notes, and snippets.

@lesutton
lesutton / Form.event.options
Last active June 12, 2018 17:51
This XSLT can be used to convert your XML response in an AEM JEE process to a JSON response that can be used by your AEM Forms Dropdown Lists. Replace the Groups/Group with the parent and repeating element in your XML then the getCommonName with your required value and the getDescription with your required description.
/*
The AJAX code to fetch the values would be placed in your form dropdown options event
with the url value being replaced with your REST URL. In this case, "userId" is an
input variable expected by the process. Retrieve the full REST URL by selecting your
"Default Start Point" in Workbench. From the properties panel, copy from the first "/"
to the version number. Omit the version number if you don't wish to target a specific
process version in the future.
*/
var v_userId = userid.value;
@lesutton
lesutton / ExtractAndSaveFormData.java
Created June 18, 2018 15:42
Setting and Getting Values from an AEM Workflow
package com.aem.workflowstep;
import com.adobe.granite.workflow.WorkflowException;
import com.adobe.granite.workflow.WorkflowSession;
import com.adobe.granite.workflow.exec.WorkItem;
import com.adobe.granite.workflow.exec.WorkflowData;
import com.adobe.granite.workflow.exec.WorkflowProcess;
import com.adobe.granite.workflow.metadata.MetaDataMap;
import org.osgi.framework.Constants;
import org.osgi.service.component.annotations.Component;
@lesutton
lesutton / main.js
Created June 27, 2018 20:18
AEM Forms Adaptive Form Detect Form Submission and Field Change Events - Client Library Entry
// Add listeners to detect when field focus changes and when form is submitted
window.addEventListener("bridgeInitializeStart", function (){
guideBridge.connect(function () {
guideBridge.on("elementFocusChanged", function (event,data) {
fieldFocus(data);
});
guideBridge.on("submitStart", function (event,data) {
formSubmit(data,event);
});
@lesutton
lesutton / styles.css
Created July 30, 2018 16:54
Adaptive form text field used for inline detailed error messages.
/*
Adaptive form text field used for inline detailed error messages.
*/
.alertMessageText input{
border-color: transparent;
font-size: 1.25em;
background: yellow;
color: red;
text-align: center;
font-weight: bold;
@lesutton
lesutton / SetWorkflowStatus.java
Created August 1, 2018 19:32
A simple example showing how to create a service that updates the value of a workflow variable named "var_Status".
package com.adobe.core.forms.workflow;
import com.adobe.granite.workflow.WorkflowException;
import com.adobe.granite.workflow.WorkflowSession;
import com.adobe.granite.workflow.exec.Route;
import com.adobe.granite.workflow.exec.WorkItem;
import com.adobe.granite.workflow.exec.WorkflowProcess;
import com.adobe.granite.workflow.metadata.MetaDataMap;
import org.apache.felix.scr.annotations.Component;
@lesutton
lesutton / actionTaken_Approve.ecma
Created August 1, 2018 19:59
Simple action taken ECMA script for use with AEM workflow task assignment result branches.
function check(){
var action = workflowData.getMetaDataMap().get("actionTaken","");
return action=="Approve";
}
@lesutton
lesutton / RetrieveAndClaimUserTasks.java
Created August 16, 2018 15:20
AEM Forms JEE Example to Retrieve and Claim User Tasks
package com.adobe.aem.forms;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import java.util.logging.Level;
@lesutton
lesutton / FormPost.class
Created September 7, 2018 16:47
Quick Example / Starting Point for a REST end point to Submit an AEM Adaptive Form to
package com.adobe.aem.forms.servlets;
import java.io.IOException;
import javax.servlet.ServletException;
import org.apache.felix.scr.annotations.sling.SlingServlet;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.slf4j.Logger;
//function to clear values of child nodes of given node
function clearChildNodes (currentNode, visibleFlag, visibleValue) {
//console.log('search child nodes for: ' + currentNode.name);
if(currentNode.items != null && currentNode.getAttribute('sling:resourceType') != 'fd/af/components/guidedropdownlist') {
//console.log('child size:' + currentNode.items.length);
if (visibleFlag == visibleValue){
//console.log('do nothing');
}
else{
//console.log('clear child nodes...');
function clearEntirePanel(currentNode) {
if(currentNode.items != null && currentNode.getAttribute('sling:resourceType') != 'fd/af/components/guidedropdownlist') {
var arrayLength = currentNode.items.length;
for (var i = 0; i < arrayLength; i++) {
var childNode = currentNode.items[i];
var nodeName = childNode.name;
var nodeType = childNode.getAttribute('sling:resourceType');
if (nodeType == 'fd/af/components/guideradiobutton' || nodeType == 'fd/af/components/guidetextbox' || nodeType == 'fd/af/components/guidedropdownlist' || nodeType == 'fd/af/components/guidecheckbox' || nodeType == 'fd/af/components/guidedatepicker' || nodeType == 'fd/af/components/guidefileupload' || nodeType == 'fd/af/components/guidenumericbox'){
if (nodeType == 'fd/af/components/guidefileupload'){
childNode.fileAttachment.value = null;