Giter Club home page Giter Club logo

fdm's Introduction

FDM

Forms Data Model - JSON Schema

Setup

  • 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';

Run

  • node acs-profile.js

Test

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.

Define a datasource in AEM

Create the Forms Data Model in AEM

fdm.png

Define the read/write methods

  • Select "Profile" under "DEFAULT SCHEMA" and "Add Selected"
  • In the dialog, click "Add"
  • Save

fdm2.png

  • 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

Define how the parameter for the read service should be identified

  • 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

Test your read service

  • 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:

fdm3.png

  • You should see your ACS Profile result in the output panel

Test your write service

  • 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)

fdm4.png

Additional services

The json schema exposes some additional services that can be used to optimize the form filling experience:

Fetch a ACS Profile via its email address

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.

Fetch a Postalcode information

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.

fdm5.png

  • 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"

fdm6.png

Test the services

You can test the services by selecting one of them and choose "Test Service" from the top menu

fdm7.png

fdm8.png

Use the Form Data Model in an AEM Form

Send me an email - Rule

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);;

fdm's People

Contributors

mmeewis avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.