<?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: Create &amp;quot;Name&amp;quot; of record based on Multiple Text Property Values in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/Create-quot-Name-quot-of-record-based-on-Multiple-Text-Property/m-p/515480#M48046</link>
    <description>&lt;P&gt;There's &lt;A href="https://legacydocs.hubspot.com/docs/methods/forms/advanced_form_options" target="_blank" rel="noopener"&gt;this&lt;/A&gt; page, specifically the example of running a script when a form submits. If you have a hidden field in your form for the ticket name, you could do something like this on submit (I've put in guesses as to what the field names would be):&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;&amp;lt;!--[if lte IE 8]&amp;gt;
    &amp;lt;script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2-legacy.js"&amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;![endif]--&amp;gt;
    &amp;lt;script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2.js"&amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;script&amp;gt;
      hbspt.forms.create({
      portalId: "[PORTAL ID]",
      formId: "[FORM ID]",
        onFormSubmit: function(form){
            var firstName = form.querySelector('input[name="firstname"]').value;
            var lastName = form.querySelector('input[name="lastname"]').value;
            var leadSource = form.querySelector('input[name="lead_source"]').value;
            var date = new Date();
            date = date.toLocaleDateString('en-GB'); // will give you date in dd/mm/yyyy format
            form.querySelector('input[name="ticket_name"]').value = `${firstName} ${lastName} - ${leadSource} ${date}`;
        }
      });
    &amp;lt;/script&amp;gt;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There's one downside to this method. If you're redirecting to another page, e.g. a thank you page, that redirection might happen before the above code executes and the form is sent. It would be fine with a thank you message.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another method, which will make sure data is changed and sent before any redirection happens if you're using a redirect, is this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;{% form
form_to_use="{{ module.form.form_id }}"
response_response_type="{{ module.form.response_type }}"
response_message="{{ module.form.message }}"
%}
{% if module.form.redirect_id %}
&amp;lt;script&amp;gt;
  window.addEventListener('message', event =&amp;gt; {
    if(event.data.type === 'hsFormCallback' &amp;amp;&amp;amp; event.data.eventName === 'onFormSubmit') {
    	let firstName = event.data.data.find(o =&amp;gt; o.name === 'firstname');
    	let lastName = event.data.data.find(o =&amp;gt; o.name === 'lastname');
    	let leadSource = event.data.data.find(o =&amp;gt; o.name === 'lead_source');
		var date = new Date();
        date = date.toLocaleDateString('en-GB'); // will give you date in dd/mm/yyyy format
        form.querySelector('input[name="ticket_name"]').value = `${firstName.value} ${lastName.value} - ${leadSource.value} ${date}`;
      
    }
    if(event.data.type === 'hsFormCallback' &amp;amp;&amp;amp; event.data.eventName === 'onFormSubmitted') {
        {% set redirect = content_by_id(module.form.redirect_id) %}
        window.location = '{{redirect.absolute_url}}'
    }
  });
&amp;lt;/script&amp;gt;
{% endif %}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 25 Oct 2021 16:52:04 GMT</pubDate>
    <dc:creator>piersg</dc:creator>
    <dc:date>2021-10-25T16:52:04Z</dc:date>
    <item>
      <title>Create "Name" of record based on Multiple Text Property Values</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Create-quot-Name-quot-of-record-based-on-Multiple-Text-Property/m-p/513814#M47938</link>
      <description>&lt;P&gt;I want to autocreate the "Ticket Name" field based on the selection of the subsequent properties. Ideally I would like it to look something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#339966"&gt;&lt;STRONG&gt;First Name + Last Name +" - " + Lead Source + date &lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;John Smith - CSG Webinar 9/5/2021&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;It looks like you can only create calculations based on number values&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;and it doesn't look like I can copy and join multiple single line property values from different objects into one target property field.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;I couldn't find a solution in any of the other discussions - so any advice would be welcome.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Oct 2021 14:41:28 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Create-quot-Name-quot-of-record-based-on-Multiple-Text-Property/m-p/513814#M47938</guid>
      <dc:creator>aljones</dc:creator>
      <dc:date>2021-10-21T14:41:28Z</dc:date>
    </item>
    <item>
      <title>Re: Create "Name" of record based on Multiple Text Property Values</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Create-quot-Name-quot-of-record-based-on-Multiple-Text-Property/m-p/514517#M47988</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/259892"&gt;@aljones&lt;/a&gt; , how are you creating the records?&amp;nbsp; Via a form?&lt;/P&gt;
&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/103660"&gt;@piersg&lt;/a&gt; might have some thoughts.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Oct 2021 15:53:54 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Create-quot-Name-quot-of-record-based-on-Multiple-Text-Property/m-p/514517#M47988</guid>
      <dc:creator>dennisedson</dc:creator>
      <dc:date>2021-10-22T15:53:54Z</dc:date>
    </item>
    <item>
      <title>Re: Create "Name" of record based on Multiple Text Property Values</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Create-quot-Name-quot-of-record-based-on-Multiple-Text-Property/m-p/515301#M48024</link>
      <description>&lt;P&gt;How is the ticket being submitted? If it's a form on a website page you could do this with some JS at the point of submission.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Oct 2021 12:46:10 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Create-quot-Name-quot-of-record-based-on-Multiple-Text-Property/m-p/515301#M48024</guid>
      <dc:creator>piersg</dc:creator>
      <dc:date>2021-10-25T12:46:10Z</dc:date>
    </item>
    <item>
      <title>Re: Create "Name" of record based on Multiple Text Property Values</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Create-quot-Name-quot-of-record-based-on-Multiple-Text-Property/m-p/515385#M48030</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/13982"&gt;@dennisedson&lt;/a&gt;&amp;nbsp; - yes&amp;nbsp; - it will be via form.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Oct 2021 14:56:32 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Create-quot-Name-quot-of-record-based-on-Multiple-Text-Property/m-p/515385#M48030</guid>
      <dc:creator>aljones</dc:creator>
      <dc:date>2021-10-25T14:56:32Z</dc:date>
    </item>
    <item>
      <title>Re: Create "Name" of record based on Multiple Text Property Values</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Create-quot-Name-quot-of-record-based-on-Multiple-Text-Property/m-p/515386#M48031</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/103660"&gt;@piersg&lt;/a&gt;&amp;nbsp; thank you - can you direct me to any documentation on this?&lt;/P&gt;</description>
      <pubDate>Mon, 25 Oct 2021 14:58:53 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Create-quot-Name-quot-of-record-based-on-Multiple-Text-Property/m-p/515386#M48031</guid>
      <dc:creator>aljones</dc:creator>
      <dc:date>2021-10-25T14:58:53Z</dc:date>
    </item>
    <item>
      <title>Re: Create "Name" of record based on Multiple Text Property Values</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Create-quot-Name-quot-of-record-based-on-Multiple-Text-Property/m-p/515480#M48046</link>
      <description>&lt;P&gt;There's &lt;A href="https://legacydocs.hubspot.com/docs/methods/forms/advanced_form_options" target="_blank" rel="noopener"&gt;this&lt;/A&gt; page, specifically the example of running a script when a form submits. If you have a hidden field in your form for the ticket name, you could do something like this on submit (I've put in guesses as to what the field names would be):&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;&amp;lt;!--[if lte IE 8]&amp;gt;
    &amp;lt;script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2-legacy.js"&amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;![endif]--&amp;gt;
    &amp;lt;script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2.js"&amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;script&amp;gt;
      hbspt.forms.create({
      portalId: "[PORTAL ID]",
      formId: "[FORM ID]",
        onFormSubmit: function(form){
            var firstName = form.querySelector('input[name="firstname"]').value;
            var lastName = form.querySelector('input[name="lastname"]').value;
            var leadSource = form.querySelector('input[name="lead_source"]').value;
            var date = new Date();
            date = date.toLocaleDateString('en-GB'); // will give you date in dd/mm/yyyy format
            form.querySelector('input[name="ticket_name"]').value = `${firstName} ${lastName} - ${leadSource} ${date}`;
        }
      });
    &amp;lt;/script&amp;gt;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There's one downside to this method. If you're redirecting to another page, e.g. a thank you page, that redirection might happen before the above code executes and the form is sent. It would be fine with a thank you message.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another method, which will make sure data is changed and sent before any redirection happens if you're using a redirect, is this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;{% form
form_to_use="{{ module.form.form_id }}"
response_response_type="{{ module.form.response_type }}"
response_message="{{ module.form.message }}"
%}
{% if module.form.redirect_id %}
&amp;lt;script&amp;gt;
  window.addEventListener('message', event =&amp;gt; {
    if(event.data.type === 'hsFormCallback' &amp;amp;&amp;amp; event.data.eventName === 'onFormSubmit') {
    	let firstName = event.data.data.find(o =&amp;gt; o.name === 'firstname');
    	let lastName = event.data.data.find(o =&amp;gt; o.name === 'lastname');
    	let leadSource = event.data.data.find(o =&amp;gt; o.name === 'lead_source');
		var date = new Date();
        date = date.toLocaleDateString('en-GB'); // will give you date in dd/mm/yyyy format
        form.querySelector('input[name="ticket_name"]').value = `${firstName.value} ${lastName.value} - ${leadSource.value} ${date}`;
      
    }
    if(event.data.type === 'hsFormCallback' &amp;amp;&amp;amp; event.data.eventName === 'onFormSubmitted') {
        {% set redirect = content_by_id(module.form.redirect_id) %}
        window.location = '{{redirect.absolute_url}}'
    }
  });
&amp;lt;/script&amp;gt;
{% endif %}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Oct 2021 16:52:04 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Create-quot-Name-quot-of-record-based-on-Multiple-Text-Property/m-p/515480#M48046</guid>
      <dc:creator>piersg</dc:creator>
      <dc:date>2021-10-25T16:52:04Z</dc:date>
    </item>
    <item>
      <title>Re: Create "Name" of record based on Multiple Text Property Values</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Create-quot-Name-quot-of-record-based-on-Multiple-Text-Property/m-p/515666#M48060</link>
      <description>&lt;P&gt;thanks&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/103660"&gt;@piersg&lt;/a&gt;&amp;nbsp; - hopefully this works for us!&lt;/P&gt;</description>
      <pubDate>Mon, 25 Oct 2021 20:15:34 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Create-quot-Name-quot-of-record-based-on-Multiple-Text-Property/m-p/515666#M48060</guid>
      <dc:creator>aljones</dc:creator>
      <dc:date>2021-10-25T20:15:34Z</dc:date>
    </item>
  </channel>
</rss>

