<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Code to standardize state/region in Data Hub</title>
    <link>https://community.hubspot.com/t5/Data-Hub/Code-to-standardize-state-region/m-p/589825#M719</link>
    <description>&lt;P&gt;Man. I've never seen this before. Without being able to dig into the workflow itself and poke around, I'm probably not going to be able to fix it. At this point, your best bet is probably to reach out to our Support team and see if they can get to the bottom of it. Sorry not to be more help!&lt;/P&gt;</description>
    <pubDate>Mon, 07 Mar 2022 18:40:36 GMT</pubDate>
    <dc:creator>KyleJepson</dc:creator>
    <dc:date>2022-03-07T18:40:36Z</dc:date>
    <item>
      <title>Code to standardize state/region</title>
      <link>https://community.hubspot.com/t5/Data-Hub/Code-to-standardize-state-region/m-p/410068#M79</link>
      <description>&lt;P&gt;This code takes two-letter abbreviations from the State/Region property and outputs the full name. Works for all U.S. states and territories and Canadian providences. If you want it to work in other places, you'll have to expand the list of abbreviations yourself &lt;span class="lia-unicode-emoji" title=":face_with_tongue:"&gt;😛&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;const hubspot = require('@hubspot/api-client');

let abbreviations = new Map();
abbreviations.set('AL', 'Alabama');
abbreviations.set('AK', 'Alaska');
abbreviations.set('AS', 'American Samoa');
abbreviations.set('AZ', 'Arizona');
abbreviations.set('AR', 'Arkansas');
abbreviations.set('AA', 'Armed Forces Americas');
abbreviations.set('AE', 'Armed Forces Europe');
abbreviations.set('AP', 'Armed Forces Pacific');
abbreviations.set('CA', 'California');
abbreviations.set('CO', 'Colorado');
abbreviations.set('CT', 'Connecticut');
abbreviations.set('DE', 'Delaware');
abbreviations.set('DC', 'District Of Columbia');
abbreviations.set('FL', 'Florida');
abbreviations.set('GA', 'Georgia');
abbreviations.set('GU', 'Guam');
abbreviations.set('HI', 'Hawaii');
abbreviations.set('ID', 'Idaho');
abbreviations.set('IL', 'Illinois');
abbreviations.set('IN', 'Indiana');
abbreviations.set('IA', 'Iowa');
abbreviations.set('KS', 'Kansas');
abbreviations.set('KY', 'Kentucky');
abbreviations.set('LA', 'Louisiana');
abbreviations.set('ME', 'Maine');
abbreviations.set('MH', 'Marshall Islands');
abbreviations.set('MD', 'Maryland');
abbreviations.set('MA', 'Massachusetts');
abbreviations.set('MI', 'Michigan');
abbreviations.set('MN', 'Minnesota');
abbreviations.set('MS', 'Mississippi');
abbreviations.set('MO', 'Missouri');
abbreviations.set('MT', 'Montana');
abbreviations.set('NE', 'Nebraska');
abbreviations.set('NV', 'Nevada');
abbreviations.set('NH', 'New Hampshire');
abbreviations.set('NJ', 'New Jersey');
abbreviations.set('NM', 'New Mexico');
abbreviations.set('NY', 'New York');
abbreviations.set('NC', 'North Carolina');
abbreviations.set('ND', 'North Dakota');
abbreviations.set('NP', 'Northern Mariana Islands');
abbreviations.set('OH', 'Ohio');
abbreviations.set('OK', 'Oklahoma');
abbreviations.set('OR', 'Oregon');
abbreviations.set('PA', 'Pennsylvania');
abbreviations.set('PR', 'Puerto Rico');
abbreviations.set('RI', 'Rhode Island');
abbreviations.set('SC', 'South Carolina');
abbreviations.set('SD', 'South Dakota');
abbreviations.set('TN', 'Tennessee');
abbreviations.set('TX', 'Texas');
abbreviations.set('VI', 'US Virgin Islands');
abbreviations.set('UT', 'Utah');
abbreviations.set('VT', 'Vermont');
abbreviations.set('VA', 'Virginia');
abbreviations.set('WA', 'Washington');
abbreviations.set('WV', 'West Virginia');
abbreviations.set('WI', 'Wisconsin');
abbreviations.set('WY', 'Wyoming');
abbreviations.set('AB', 'Alberta');
abbreviations.set('BC', 'British Columbia');
abbreviations.set('MB', 'Manitoba');
abbreviations.set('NB', 'New Brunswick');
abbreviations.set('NF', 'Newfoundland');
abbreviations.set('NT', 'Northwest Territory');
abbreviations.set('NS', 'Nova Scotia');
abbreviations.set('NU', 'Nunavut');
abbreviations.set('ON', 'Ontario');
abbreviations.set('PE', 'Prince Edward Island');
abbreviations.set('QC', 'Quebec');
abbreviations.set('SK', 'Saskatchewan');
abbreviations.set('YT', 'Yukon');

exports.main = (event, callback) =&amp;gt; {
  const hubspotClient = new hubspot.Client({
    apiKey: process.env.HAPIKEY
  });
  hubspotClient.crm.contacts.basicApi.getById(event.object.objectId, ["state"])
    .then(results =&amp;gt; {
      let state = results.body.properties.state;
      let test = state.toUpperCase();
      let output;
if (abbreviations.has(test)) {
  output = abbreviations.get(test);
} else {
  output = state;
}
      callback({
        outputFields: {
          output: output
        }
      });
    })
    .catch(err =&amp;gt; {
      console.error(err);
    });
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This doesn't actually update the record. To do that, you'll need to add a workflow action that copies the output value from the code into the State/Region contact property. (Or add an additional API call to the code to update the property.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;TO MAKE THIS WORK FOR COMPANIES: Change &lt;FONT face="courier new,courier" color="#FF0000"&gt;contacts&lt;/FONT&gt; to &lt;FONT face="courier new,courier" color="#FF0000"&gt;companies&lt;/FONT&gt; in &lt;FONT face="courier new,courier" color="#FF0000"&gt;hubspotClient.crm.contacts.basicApi.getById&lt;/FONT&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;TO MAKE THIS WORK THE OTHER WAY AROUND: Would take a few extra steps. This code takes the value from State/Region, uses &lt;FONT color="#FF0000"&gt;.toUpperCase&lt;/FONT&gt; to make it ALL CAPS, and then searches the list of abbreviations (which are also ALL CAPS) to look for matches. There isn't a standard method like &lt;FONT color="#FF0000"&gt;.toUpperCase&lt;/FONT&gt; that puts things in Title Case, and the &lt;FONT color="#FF0000"&gt;.has&lt;/FONT&gt; method for maps is case sensitive. Luckily, the Data Format action (also included in Operations Hub) does all kinds of things with capitalization, so you could do it that way. I think maybe the easiest thing to do is to reverse the list of abbreviations and make the state names ALL UPPERCASE like the abbreviation are.&amp;nbsp;Then use the code basically like it is. The output of this code could be pulled into a Data Format action to fix the capitalization, and then copy the output of the Data Format action into the property.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;OTHER NOTES: This works great if all your State/Region values are two-letter abbreviations or properly spelled/capitalized full names. If you have people using old fashioned abbreviations (Ill. for Illinois, Mass. for Massachusetts, Minn. for Minnesota) or if you have typoes (Texsa for Texas), this won't help with that. In a future world, when custom-coded actions can be used in branching logic, it would be worthwhile to have a code that takes State/Region and, if the value isn't found in the array below, it creates a task and assigns it to the contact owner to have them fix the problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;['AL', 'Alabama', 'AK', 'Alaska', 'AS', 'American Samoa', 'AZ', 'Arizona', 'AR', 'Arkansas', 'AA', 'Armed Forces Americas', 'AE', 'Armed Forces Europe', 'AP', 'Armed Forces Pacific', 'CA', 'California', 'CO', 'Colorado', 'CT', 'Connecticut', 'DE', 'Delaware', 'DC', 'District Of Columbia', 'FL', 'Florida', 'GA', 'Georgia', 'GU', 'Guam', 'HI', 'Hawaii', 'ID', 'Idaho', 'IL', 'Illinois', 'IN', 'Indiana', 'IA', 'Iowa', 'KS', 'Kansas', 'KY', 'Kentucky', 'LA', 'Louisiana', 'ME', 'Maine', 'MH', 'Marshall Islands', 'MD', 'Maryland', 'MA', 'Massachusetts', 'MI', 'Michigan', 'MN', 'Minnesota', 'MS', 'Mississippi', 'MO', 'Missouri', 'MT', 'Montana', 'NE', 'Nebraska', 'NV', 'Nevada', 'NH', 'New Hampshire', 'NJ', 'New Jersey', 'NM', 'New Mexico', 'NY', 'New York', 'NC', 'North Carolina', 'ND', 'North Dakota', 'NP', 'Northern Mariana Islands', 'OH', 'Ohio', 'OK', 'Oklahoma', 'OR', 'Oregon', 'PA', 'Pennsylvania', 'PR', 'Puerto Rico', 'RI', 'Rhode Island', 'SC', 'South Carolina', 'SD', 'South Dakota', 'TN', 'Tennessee', 'TX', 'Texas', 'VI', 'US Virgin Islands', 'UT', 'Utah', 'VT', 'Vermont', 'VA', 'Virginia', 'WA', 'Washington', 'WV', 'West Virginia', 'WI', 'Wisconsin', 'WY', 'Wyoming', 'AB', 'Alberta', 'BC', 'British Columbia', 'MB', 'Manitoba', 'NB', 'New Brunswick', 'NF', 'Newfoundland', 'NT', 'Northwest Territory', 'NS', 'Nova Scotia', 'NU', 'Nunavut', 'ON', 'Ontario', 'PE', 'Prince Edward Island', 'QC', 'Quebec', 'SK', 'Saskatchewan', 'YT', 'Yukon']&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 May 2021 18:51:43 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Data-Hub/Code-to-standardize-state-region/m-p/410068#M79</guid>
      <dc:creator>KyleJepson</dc:creator>
      <dc:date>2021-05-10T18:51:43Z</dc:date>
    </item>
    <item>
      <title>Re: Code to standardize state/region</title>
      <link>https://community.hubspot.com/t5/Data-Hub/Code-to-standardize-state-region/m-p/589733#M714</link>
      <description>&lt;P&gt;This is great,&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/397"&gt;@KyleJepson&lt;/a&gt;&amp;nbsp;! All about that data cleanliness&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":clapping_hands:"&gt;👏&lt;/span&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I'm using this custom code to update Companies (I did change&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;FONT face="courier new,courier" color="#FF0000"&gt;contacts&lt;/FONT&gt;&lt;SPAN&gt;&amp;nbsp;to&amp;nbsp;&lt;/SPAN&gt;&lt;FONT face="courier new,courier" color="#FF0000"&gt;companies&lt;/FONT&gt;&lt;SPAN&gt;&amp;nbsp;in&amp;nbsp;&lt;/SPAN&gt;&lt;FONT face="courier new,courier" color="#FF0000"&gt;hubspotClient.crm.contacts.basicApi.getById&lt;/FONT&gt;&lt;SPAN&gt;), but am having trouble with the output. The code successfully executes but continues to fail when the&amp;nbsp;&lt;FONT face="courier new,courier" color="#FF0000"&gt;state&amp;nbsp;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN&gt;string value is meant to copy over. Any thoughts?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2022-03-07 at 10.04.55 AM.png" style="width: 400px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/61083i03B9F5B4C283C330/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screen Shot 2022-03-07 at 10.04.55 AM.png" alt="Screen Shot 2022-03-07 at 10.04.55 AM.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2022-03-07 at 10.03.39 AM.png" style="width: 400px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/61082iBE8F7B106ED9E584/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screen Shot 2022-03-07 at 10.03.39 AM.png" alt="Screen Shot 2022-03-07 at 10.03.39 AM.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2022 17:07:00 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Data-Hub/Code-to-standardize-state-region/m-p/589733#M714</guid>
      <dc:creator>callie</dc:creator>
      <dc:date>2022-03-07T17:07:00Z</dc:date>
    </item>
    <item>
      <title>Re: Code to standardize state/region</title>
      <link>https://community.hubspot.com/t5/Data-Hub/Code-to-standardize-state-region/m-p/589811#M717</link>
      <description>&lt;P&gt;Hmmmm, that's very strange. When you click into the error, does it give you any details?&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2022 18:27:21 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Data-Hub/Code-to-standardize-state-region/m-p/589811#M717</guid>
      <dc:creator>KyleJepson</dc:creator>
      <dc:date>2022-03-07T18:27:21Z</dc:date>
    </item>
    <item>
      <title>Re: Code to standardize state/region</title>
      <link>https://community.hubspot.com/t5/Data-Hub/Code-to-standardize-state-region/m-p/589814#M718</link>
      <description>&lt;P&gt;Unfortunately, just the simple "Error: Unable to update property" =/&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2022 18:29:58 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Data-Hub/Code-to-standardize-state-region/m-p/589814#M718</guid>
      <dc:creator>callie</dc:creator>
      <dc:date>2022-03-07T18:29:58Z</dc:date>
    </item>
    <item>
      <title>Re: Code to standardize state/region</title>
      <link>https://community.hubspot.com/t5/Data-Hub/Code-to-standardize-state-region/m-p/589825#M719</link>
      <description>&lt;P&gt;Man. I've never seen this before. Without being able to dig into the workflow itself and poke around, I'm probably not going to be able to fix it. At this point, your best bet is probably to reach out to our Support team and see if they can get to the bottom of it. Sorry not to be more help!&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2022 18:40:36 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Data-Hub/Code-to-standardize-state-region/m-p/589825#M719</guid>
      <dc:creator>KyleJepson</dc:creator>
      <dc:date>2022-03-07T18:40:36Z</dc:date>
    </item>
    <item>
      <title>Re: Code to standardize state/region</title>
      <link>https://community.hubspot.com/t5/Data-Hub/Code-to-standardize-state-region/m-p/589826#M720</link>
      <description>&lt;P&gt;No sweat, appreciate the initial snippet to start with nonetheless. Thanks, Kyle!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2022 18:41:27 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Data-Hub/Code-to-standardize-state-region/m-p/589826#M720</guid>
      <dc:creator>callie</dc:creator>
      <dc:date>2022-03-07T18:41:27Z</dc:date>
    </item>
    <item>
      <title>Re: Code to standardize state/region</title>
      <link>https://community.hubspot.com/t5/Data-Hub/Code-to-standardize-state-region/m-p/672530#M959</link>
      <description>&lt;P&gt;Hi Callie, were you able to resolve the error? I'm getting the same thing.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the log:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;WARNING: The logs for this function have exceeded the 4KB limit.
...
sWritten)]: 178,
      [Symbol(connect-options)]: [Object]
    },
    _consuming: false,
    _dumped: false,
    req: ClientRequest {
      _events: [Object: null prototype],
      _eventsCount: 5,
      _maxListeners: undefined,
      outputData: [],
      outputSize: 0,
      writable: true,
      _last: true,
      chunkedEncoding: false,
      shouldKeepAlive: false,
      _defaultKeepAlive: true,
      useChunkedEncodingByDefault: false,
      sendDate: false,
      _removedConnection: false,
      _removedContLen: false,
      _removedTE: false,
      _contentLength: 0,
      _hasBody: true,
      _trailer: '',
      finished: true,
      _headerSent: true,
      socket: [TLSSocket],
      connection: [TLSSocket],
      _header: 'GET /crm/v3/objects/contacts/164868?properties=state HTTP/1.1\r\n' +
        'User-Agent: hubspot-api-client-nodejs; 3.4.1\r\n' +
        'Accept: application/json\r\n' +
        'host: api.hubapi.com\r\n' +
        'Connection: close\r\n' +
        '\r\n',
      _keepAliveTimeout: 0,
      _onPendingData: [Function: noopPendingOutput],
      agent: [Agent],
      socketPath: undefined,
      method: 'GET',
      insecureHTTPParser: undefined,
      path: '/crm/v3/objects/contacts/164868?properties=state',
      _ended: true,
      res: [Circular],
      aborted: false,
      timeoutCb: null,
      upgradeOrConnect: false,
      parser: null,
      maxHeadersCount: null,
      reusedSocket: false,
      host: 'api.hubapi.com',
      protocol: 'https:',
      [Symbol(kCapture)]: false,
      [Symbol(kNeedDrain)]: false,
      [Symbol(corked)]: 0,
      [Symbol(kOutHeaders)]: [Object: null prototype]
    },
    request: Request {
      _events: [Object: null prototype],
      _eventsCount: 5,
      _maxListeners: undefined,
      method: 'GET',
      headers: [Object],
      uri: [Url],
      useQuerystring: true,
      callback: [Function],
      readable: true,
      writable: true,
      explicitMethod: true,
      _qs: [Querystring],
      _auth: [Auth],
      _oauth: [OAuth],
      _multipart: [Multipart],
      _redirect: [Redirect],
      _tunnel: [Tunnel],
      setHeader: [Function],
      hasHeader: [Function],
      getHeader: [Function],
      removeHeader: [Function],
      localAddress: undefined,
      pool: {},
      dests: [],
      __isRequestRequest: true,
      _callback: [Function],
      proxy: null,
      tunnel: true,
      setHost: true,
      originalCookieHeader: undefined,
      _disableCookies: true,
      _jar: undefined,
      port: 443,
      host: 'api.hubapi.com',
      url: [Url],
      path: '/crm/v3/objects/contacts/164868?properties=state',
      _json: true,
      httpModule: [Object],
      agentClass: [Function: Agent],
      agent: [Agent],
      _started: true,
      href: 'https://api.hubapi.com/crm/v3/objects/contacts/164868?properties=state',
      req: [ClientRequest],
      ntick: true,
      response: [Circular],
      originalHost: 'api.hubapi.com',
      originalHostHeaderName: 'host',
      responseContent: [Circular],
      _destdata: true,
      _ended: true,
      _callbackCalled: true,
      [Symbol(kCapture)]: false
    },
    toJSON: [Function: responseToJSON],
    caseless: Caseless { dict: [Object] },
    body: {
      status: 'error',
      message: 'Authentication credentials not found. This API supports both API Key and OAuth 2.0 authentication and you can find more details at https://developers.hubspot.com/docs/methods/auth/oauth-overview',
      correlationId: '5ccca1ce-6f6f-4857-b754-e9e3f61afd66',
      category: 'INVALID_AUTHENTICATION'
    },
    [Symbol(kCapture)]: false
  },
  body: SimplePublicObject {
    id: undefined,
    properties: undefined,
    createdAt: undefined,
    updatedAt: undefined,
    associations: undefined,
    archived: undefined,
    archivedAt: undefined
  },
  statusCode: 401
}

Memory: 105/128 MB
Runtime: 1369.83 ms&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jul 2022 23:09:01 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Data-Hub/Code-to-standardize-state-region/m-p/672530#M959</guid>
      <dc:creator>nicole388</dc:creator>
      <dc:date>2022-07-28T23:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: Code to standardize state/region</title>
      <link>https://community.hubspot.com/t5/Data-Hub/Code-to-standardize-state-region/m-p/672547#M961</link>
      <description>&lt;P&gt;We did! The code is below! Keep in mind, this utilizes a Private App token instead of the API key, as the API key will be sunset next quarter &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;const hubspot = require('@hubspot/api-client');&lt;/P&gt;&lt;P&gt;let abbreviations = new Map();&lt;BR /&gt;abbreviations.set('ALABAMA', 'AL');&lt;BR /&gt;abbreviations.set('ALASKA', 'AK');&lt;BR /&gt;abbreviations.set('ARIZONA', 'AZ');&lt;BR /&gt;abbreviations.set('ARKANSAS', 'AR');&lt;BR /&gt;abbreviations.set('CALIFORNIA', 'CA');&lt;BR /&gt;abbreviations.set('COLORADO', 'CO');&lt;BR /&gt;abbreviations.set('CONNECTICUT', 'CT');&lt;BR /&gt;abbreviations.set('DELAWARE', 'DE');&lt;BR /&gt;abbreviations.set('DISTRICT OF COLUMBIA', 'DC');&lt;BR /&gt;abbreviations.set('FLORIDA', 'FL');&lt;BR /&gt;abbreviations.set('GEORGIA', 'GA');&lt;BR /&gt;abbreviations.set('HAWAII', 'HI');&lt;BR /&gt;abbreviations.set('IDAHO', 'ID');&lt;BR /&gt;abbreviations.set('ILLINOIS', 'IL');&lt;BR /&gt;abbreviations.set('INDIANA', 'IN');&lt;BR /&gt;abbreviations.set('IOWA', 'IA');&lt;BR /&gt;abbreviations.set('KANSAS', 'KS');&lt;BR /&gt;abbreviations.set('KENTUCKY', 'KY');&lt;BR /&gt;abbreviations.set('LOUISIANA', 'LA');&lt;BR /&gt;abbreviations.set('MAINE', 'ME');&lt;BR /&gt;abbreviations.set('MARYLAND', 'MD');&lt;BR /&gt;abbreviations.set('MASSACHUSETTS', 'MA');&lt;BR /&gt;abbreviations.set('MICHIGAN', 'MI');&lt;BR /&gt;abbreviations.set('MINNESOTA', 'MN');&lt;BR /&gt;abbreviations.set('MISSISSIPPI', 'MS');&lt;BR /&gt;abbreviations.set('MISSOURI', 'MO');&lt;BR /&gt;abbreviations.set('MONTANA', 'MT');&lt;BR /&gt;abbreviations.set('NEBRASKA', 'NE');&lt;BR /&gt;abbreviations.set('NEVADA', 'NV');&lt;BR /&gt;abbreviations.set('NEW HAMPSHIRE', 'NH');&lt;BR /&gt;abbreviations.set('NEW JERSEY', 'NJ');&lt;BR /&gt;abbreviations.set('NEW MEXICO', 'NM');&lt;BR /&gt;abbreviations.set('NEW YORK', 'NY');&lt;BR /&gt;abbreviations.set('NORTH CAROLINA', 'NC');&lt;BR /&gt;abbreviations.set('NORTH DAKOTA', 'ND');&lt;BR /&gt;abbreviations.set('OHIO', 'OH');&lt;BR /&gt;abbreviations.set('OKLAHOMA', 'OK');&lt;BR /&gt;abbreviations.set('OREGON', 'OR');&lt;BR /&gt;abbreviations.set('PENNSYLVANIA', 'PA');&lt;BR /&gt;abbreviations.set('RHODE ISLAND', 'RI');&lt;BR /&gt;abbreviations.set('SOUTH CAROLINA', 'SC');&lt;BR /&gt;abbreviations.set('SOUTH DAKOTA', 'SD');&lt;BR /&gt;abbreviations.set('TENNESSEE', 'TN');&lt;BR /&gt;abbreviations.set('TEXAS', 'TX');&lt;BR /&gt;abbreviations.set('UTAH', 'UT');&lt;BR /&gt;abbreviations.set('VERMONT', 'VT');&lt;BR /&gt;abbreviations.set('VIRGINIA', 'VA');&lt;BR /&gt;abbreviations.set('WASHINGTON', 'WA');&lt;BR /&gt;abbreviations.set('WEST VIRGINIA', 'WV');&lt;BR /&gt;abbreviations.set('WISCONSIN', 'WI');&lt;BR /&gt;abbreviations.set('WYOMING', 'WY');&lt;/P&gt;&lt;P&gt;exports.main = (event, callback) =&amp;gt; {&lt;BR /&gt;const hubspotClient = new hubspot.Client({&lt;BR /&gt;accessToken: process.env.HAPI_PrivateApp&lt;BR /&gt;});&lt;BR /&gt;hubspotClient.crm.companies.basicApi.getById(event.object.objectId, ["state"])&lt;BR /&gt;.then(results =&amp;gt; {&lt;BR /&gt;let state = results.body.properties.state;&lt;BR /&gt;let test = state.toUpperCase();&lt;BR /&gt;let output;&lt;BR /&gt;if (abbreviations.has(test)) {&lt;BR /&gt;output = abbreviations.get(test);&lt;BR /&gt;} else {&lt;BR /&gt;output = state;&lt;BR /&gt;}&lt;BR /&gt;callback({&lt;BR /&gt;outputFields: {&lt;BR /&gt;output: output&lt;BR /&gt;}&lt;BR /&gt;});&lt;BR /&gt;})&lt;BR /&gt;.catch(err =&amp;gt; {&lt;BR /&gt;console.error(err);&lt;BR /&gt;});&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jul 2022 00:41:32 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Data-Hub/Code-to-standardize-state-region/m-p/672547#M961</guid>
      <dc:creator>callie</dc:creator>
      <dc:date>2022-07-29T00:41:32Z</dc:date>
    </item>
  </channel>
</rss>

