Leads not dropping into Salesforce anymore

For some reason, the leads stopped dropping into Salesforce as of june 10th, 2022.

These are leads upon first sign in using Auth0. Does anyone know if something changed in SF? Both the rule and application on SF are connecting and triggering - just nothing is coming through anymore…

Any tips on where to look at the issue?

Hi @javajiver,

Are you still seeing this issue? I would suggest checking your Auth0 Tenant Logs during that time period.

I’m having the same issue. Checked logs but didn’t find any thing that stood out. Not receiving any errors.

Hi @jyoung,

Could you give us some more details about your setup? How are you getting data from Auth0 to SF?

Hi Dan,

Thanks for your help!

I’m using this rule:

function createLeadSalesforce(user, context, callback) {
  user.app_metadata = user.app_metadata || {};
  if (user.app_metadata.recordedAsLead) {
    return callback(null, user, context);
  }

  const request = require('request');

  const MY_SLACK_WEBHOOK_URL = 'YOUR SLACK WEBHOOK URL';
  const slack = require('slack-notify')(MY_SLACK_WEBHOOK_URL);

  //Populate the variables below with appropriate values
  const SFCOM_CLIENT_ID = configuration.SALESFORCE_CLIENT_ID;
  const SFCOM_CLIENT_SECRET = configuration.SALESFORCE_CLIENT_SECRET;
  const USERNAME = configuration.SALESFORCE_USERNAME;
  const PASSWORD = configuration.SALESFORCE_PASSWORD;

  getAccessToken(
    SFCOM_CLIENT_ID,
    SFCOM_CLIENT_SECRET,
    USERNAME,
    PASSWORD,
    (response) => {
      if (!response.instance_url || !response.access_token) {
        slack.alert({
          channel: '#some_channel',
          text: 'Error Getting SALESFORCE Access Token',
          fields: {
            error: response,
          },
        });

        return;
      }

      createLead(
        response.instance_url,
        response.access_token,
        (err, result) => {
          if (err || !result || !result.id) {
            // slack.alert({
            //   channel: '#some_channel',
            //   text: 'Error Creating SALESFORCE Lead',
            //   fields: {
            //     error: err || result
            //   }
            // });
            console.log('Error Creating SALESFORCE Lead', err || result);

            return;
          }

          user.app_metadata.recordedAsLead = true;
          auth0.users.updateAppMetadata(user.user_id, user.app_metadata);
        }
      );
    }
  );

  //See http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_lead.htm
  function createLead(url, access_token, callback) {
    //Can use many more fields
    const data = {
      LastName: user.name,
      Company: 'Web channel signups',
    };

    request.post(
      {
        url: url + '/services/data/v20.0/sobjects/Lead',
        headers: {
          Authorization: 'OAuth ' + access_token,
        },
        json: data,
      },
      (err, response, body) => {
        return callback(err, body);
      }
    );
  }

  //Obtains a SFCOM access_token with user credentials
  function getAccessToken(
    client_id,
    client_secret,
    username,
    password,
    callback
  ) {
    request.post(
      {
        url: 'https://login.salesforce.com/services/oauth2/token',
        form: {
          grant_type: 'password',
          client_id: client_id,
          client_secret: client_secret,
          username: username,
          password: password,
        },
      },
      (err, respose, body) => {
        return 'error dude';
      }
    );
  }

  // don’t wait for the SF API call to finish, return right away (the request will continue on the sandbox)`
  callback(null, user, context);
}

My configuration details for Salesforce are accurate and stored in the Rules Settings. Not sure how to troubleshoot from here, unfortunately.

Could it be related to this?

Also, just so you are aware, request has been deprecated for nearly 3 years.

Interesting, thanks! Is it possible to use Axios within Rules in Auth0?

1 Like

Yes, you can certainly use axios in rules.

However, I would suggest switching to Actions if you are planning on re-writing this rule.

1 Like

Thanks for your guidance, Dan. Appreciate it!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.