Forms Data Model - JSON Schema
-
Install Node.js
-
Install the following packages (npm install)
- express
- request
- body-parser
- fs
- axios
- jsonwebtoken
-
Copy your private key into the folder where you will run acs-profile.js
-
Edit acs-profile.js (the file included is acs-profile-obfuscated.js, it is my acs-profile.js but with all sensitive info cleared)
- From the adobe.io console copy the JWT for your integration and paste it to the jwtPayload object
// get your jwtPayload from the adobe.io console
var jwtPayload = {
"exp": 1537388667,
"iss": "xxxxxxx@AdobeOrg",
"sub": "[email protected]",
"https://ims-na1.adobelogin.com/s/ent_campaign_sdk": true,
"aud": "https://ims-na1.adobelogin.com/c/xxxxxxxxxxxxxxxxxx"
};
- Replace the "exp" by "exp": tomorrow.getTime() so that it looks like:
// get your jwtPayload from the adobe.io console
var jwtPayload = {
"exp": tomorrow.getTime(),
"iss": "xxxxxxx@AdobeOrg",
"sub": "[email protected]",
"https://ims-na1.adobelogin.com/s/ent_campaign_sdk": true,
"aud": "https://ims-na1.adobelogin.com/c/xxxxxxxxxxxxxxxxxx"
};
- Copy your clientId and clientSecret from the adobe.io console and paste it into the code
// get your clientId and clientSecret from the adobe.io console
var clientId = 'xxxxxxxxxxxxxxxxxxx';
var clientSecret = 'xxxxxxxxxxxxxxxxxx';
- node acs-profile.js
To see if the ACS connection is working properly, open the following url in your browser. This url assumes that your acs-profile app is running on 8085.
(http://localhost:8085/forms/customer/getACSProfiles)
You should get a raw ACS response that lists all your profiles.
- Navigate to (http://localhost:4502/libs/fd/fdm/gui/components/admin/fdmcloudservice/fdm.html/conf)
- Open "Global" and hit "Create"
- Enter name and title and select "RESTful" service as the Service Type
- Next
- Select "File" as the Swagger source
- Browse and uplaod "acs-swagger-datamodel-v3.json"
- Create
- Navigate to (http://localhost:4502/aem/forms.html/content/dam/formsanddocuments-fdm)
- Create
- Enter a name and select "Global" as your "Data Source Configuration"
- Next
- Select your data source created in the previous step
- Save and open in "Edit"
- Select "Profile" under "DEFAULT SCHEMA" and "Add Selected"
- In the dialog, click "Add"
- Save
- In the "Model" window select "Profile" (it should turn blue when properly selected)
- In the top menu, select "Edit Properties"
- In the "Edit Properties" panel select
- "GET /customer/getACSProfileByCustomerId/{id}" as your read service
- "POST /customer/createACSProfile" as your write service
- Edit the "Id" GET argument (a dialog appears)
- Select "Literal" and enter a known Adobe Campaign Standard "Customer Id" (requires data model extension)
- Done, Done, Save
- Select the "Profile" enity in the Model (should turn blue when selected)
- From the top menu select "Test Model Object"
- Make sure everything is set as shown in the screen below:
- You should see your ACS Profile result in the output panel
- In the "Test Model Object" screen, Select "Write Model Object" for the "Profile" entity
- A pre-populated object will be generated
- Edit the "Profile" properties (if you hit test, the profile will be created in your Adobe Campaign instance
- You can leave cusCrmid empty, it will be assigned by the service
- Hit "Test", the result should look like the screen below (cusCrmid has now a value)
The json schema exposes some additional services that can be used to optimize the form filling experience:
This method can be invoked as part of a field change rule, whenever the email field is updated, the profile information associated with the email is fetched from campaign and will be used to prefill a form fields.
This method can be invoked as part of a field change rule, whenever the postalcode field is updated, the city information will be fetched using a Belgian postalcode service.
- As shown in the screen above, select the two services and hit "Add Selected"
- Hit "Add" in the dialog that appears, as a result the "PostalCode" entity will add to your model
- Hit "Save"
You can test the services by selecting one of them and choose "Test Service" from the top menu
var operationInfo = {
"formDataModelId": "/content/dam/formsanddocuments-fdm/aem-meetup/aem-meetup",
"operationTitle": "POST /customer/sendDraftFormLink",
"operationName": "POST /customer/sendDraftFormLink_15397152131100"
};
var inputs = {
"DraftLinkEvent.email" : email_2,
"DraftLinkEvent.ctx.email" : email_2,
"DraftLinkEvent.ctx.draftId" : guideBridge.customContextProperty('draftID'),
"DraftLinkEvent.ctx.labmachinelabel" : firstName
};
var outputs = {
};
guidelib.dataIntegrationUtils.executeOperation(operationInfo, inputs, outputs);;