Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This guide proposes the best practice on how to keep the environment or environment-related keys outside of the project across multiple environments.

  1. Create a configuration new project titled “Configuration” within each environment (Dev, Stage, Prod). This is the project that we will not be moving whenever publishing our real project.

    Image RemovedImage Added
  2. Open your Engage the Configuration project.

  3. Under Develop > Schema and create a new Schema and a name for it. In this example, we will name it “settings“Settings.” We will set it as a dynamic data with one field.

  4. This will hold the key value pair between Dev, Stage, and Production.

    Image Added
  5. Now we will go to Report > Data > Settings > settings> and create a content block called settings and a name for it. For this example, we will call it “Settings A.”

    Image Added
    1. This is the key value pair we will keep here and what we will keep the same across all of the environments.

      Image Added
    2. You can add as many key values here as you

    want 
    1. want.

      Image Added
  6. Now we need to make sure this Configuration project is created with all of the same Schema and Data settings we have just created across Dev, Stage, and Production.

    1. The key is very important - we need to keep the same key across all

    environments 
    1. of the same environments.

      Image Added
  7. To use it, in Expd: 

    Inject >

    let’s go into Experience Designer of the project you are trying to set up and we will be adding in the following nodes.

    Image Added
    1. Add an Inject node and set it to after 0.1 >Function node > Set Model > set as we want it to be loaded as fast as possible.

      Image Added
    2. Then add a Function node and name it “Set Model." Set the key to the schema key key

      Image Added
    3. Add a Dynamic data Data Manager node > and program into the settings Settings

      Image Added
      1. Make sure the content name is

      the same 

      Add a debug to make sure it works 

    Write the function > Set to Global context > we
      1. the same as the one we have created

    1. Add another Function node and title it “Set to Global context.” This is where we will set Settings into the Global context for Experience Designer

      Image Added
      1. We recommend only one settings content so that

    it
      1. the below code will only return one

    Now
      1. . Otherwise, make sure the correct settings item name is used.

        Code Block
        var settings = _.get(msg, 'data.dynamicData.result[0].payload', {});
      2. We will create a key in global setting called “Config Setting” and store the settings that we have to retrieve so that we can use it whenever we need

    to Now we can test
      1. to.

        Code Block
        global.set("CONFIG_SETTING", settings);
  8. Let’s test it to see if it is working. Insert an Inject node and a Function node to Check Config.

    Image Added

Now when we click on this, it will pull the settings we’ve created as part of the content under the settings we have created within the Configuration project.

...

Info

If you change the settings within the Configuration project, it will only display if you deploy the global context again

...

.