Expand my Community achievements bar.

SOLVED

Marketo forms list not loading in prod but loading fine in stage/UAT environment

Avatar

Level 8

as above. The drop-down list that supposed to list all the Marketo forms is empty. All I get is a message that says "Unable to load forms"

setup:

  • AEM 6.5.6
  • ACS commons 4.8.6 (release version) (in our AMS hosted environment)
  • ACS commons 4.8.6 (release version),5.0.4 (release version), 5.0.5-snapshot and 5.0.7-snapshot (just downloaded yesterday via git clone) (in my local instance)

Things I did to investigate/setup Marketo in AEM:

  • I compared the contents of /apps/settings/wcm/designs/myapp/.content.xml from stage and prod (via exporting the package in CRX) via diff and there are no differences. I know I had to setup in stage so it works.
  • I followed this guide => https://adobe-consulting-services.github.io/acs-aem-commons/features/marketo-form/index.html
  • Because I cannot added the embed built-in/core component directly, I had to create a new component and extend the embed component. My new component has this => sling:resourceSuperType = core/wcm/components/embed/v1/embed
  • I have created a Marketo config via Settings => Cloud services => Marketo. This created a new node/entry in /conf/myapp/settings/cloudconfigs/Marketo
  • I also have to setup the design mode configuration for my component (configuration located in /apps/settings/wcm/designs/myapp)
  • I looked at the logs and it seems the problem is the ACS-commons/Marketo class specifically (seems the class cannot see my config even if it's there)

from ACS-commons - MarketoFormDataSource class

 

 

 

MarketoClientConfigurationManager cfgMgr = request.adaptTo(MarketoClientConfigurationManager.class);
if (cfgMgr != null) {
config = cfgMgr.getConfiguration();
}
if (config == null) {
String msg = String.format("No Marketo configuration found for resource '%s'",
request.getRequestPathInfo().getSuffix());
throw new RepositoryException(msg);
}

 

 

 

--------------

from ACS-commons - MarketoClientConfigurationManagerImpl class (this class/function returns a null - i.e. cannot see my config)

 

 

 

return configRsrcRslvr.getResourceCollection(resource, "settings", "cloudconfigs").stream().filter(c -> {
boolean matches = "/apps/acs-commons/templates/utilities/marketocloudconfig"
.equals(c.getValueMap().get("jcr:content/cq:template", ""));
log.debug("Resource: {} matches: {}", c, matches);
return matches;
}).findFirst().map(c -> c.getChild(JcrConstants.JCR_CONTENT)).map(c -> c.adaptTo(MarketoClientConfiguration.class))
.orElse(null);
}

 

1 Accepted Solution

Avatar

Correct answer by
Level 2

Hi @jayv25585659 ,

To me it seems that the configuration credentials you are using on lower environment are not correct due to which you may be getting an exception while making an API call to Marketo.

See following code snippet from MarketoFormDataSource.java

 

 options = formCache.get(config).stream()
          .sorted((MarketoForm f1, MarketoForm f2) -> f1.getName().compareTo(f2.getName())).map(f -> {
            Map<String, Object> data = new HashMap<>();
            data.put("selected", currentValue == f.getId());
            data.put("value", f.getId());
            data.put("text", String.format("%s [%s] (%s)", f.getName(), f.getLocale(), f.getId()));
            return new ValueMapResource(request.getResourceResolver(), new ResourceMetadata(), "nt:unstructured",
                new ValueMapDecorator(data));
          }).collect(Collectors.toList());
      log.debug("Loaded {} options", options.size());
    } catch (Exception e) {
      log.warn("Failed to load Marketo forms", e);
      options = new ArrayList<>();
      Map<String, Object> data = new HashMap<>();
      data.put("value", "");
      data.put("text", "Unable to load forms from Marketo");
      options.add(new ValueMapResource(request.getResourceResolver(), new ResourceMetadata(), "nt:unstructured",
          new ValueMapDecorator(data)));
    }

You can manually check making the Rest API calls as coded under MarketoClientImpl.java to first extract the bearer token and the use it to call forms API to pull in all forms details from Marketo.

 

Hope this helps!

View solution in original post

1 Reply

Avatar

Correct answer by
Level 2

Hi @jayv25585659 ,

To me it seems that the configuration credentials you are using on lower environment are not correct due to which you may be getting an exception while making an API call to Marketo.

See following code snippet from MarketoFormDataSource.java

 

 options = formCache.get(config).stream()
          .sorted((MarketoForm f1, MarketoForm f2) -> f1.getName().compareTo(f2.getName())).map(f -> {
            Map<String, Object> data = new HashMap<>();
            data.put("selected", currentValue == f.getId());
            data.put("value", f.getId());
            data.put("text", String.format("%s [%s] (%s)", f.getName(), f.getLocale(), f.getId()));
            return new ValueMapResource(request.getResourceResolver(), new ResourceMetadata(), "nt:unstructured",
                new ValueMapDecorator(data));
          }).collect(Collectors.toList());
      log.debug("Loaded {} options", options.size());
    } catch (Exception e) {
      log.warn("Failed to load Marketo forms", e);
      options = new ArrayList<>();
      Map<String, Object> data = new HashMap<>();
      data.put("value", "");
      data.put("text", "Unable to load forms from Marketo");
      options.add(new ValueMapResource(request.getResourceResolver(), new ResourceMetadata(), "nt:unstructured",
          new ValueMapDecorator(data)));
    }

You can manually check making the Rest API calls as coded under MarketoClientImpl.java to first extract the bearer token and the use it to call forms API to pull in all forms details from Marketo.

 

Hope this helps!