PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Modifying the Entry id

  1. italianbird
    Member

    Where and how can I modify the entry id? I want to change the entry id from the standard 'Entry # 5' format to 'CT001' or something similar. All the Entry id's need to lead with CT. They will be used as unique identifiers. On a time crunch, please help.

    Posted 9 years ago on Tuesday July 24, 2012 | Permalink
  2. I don't believe you will be able to change the entry ID as it is used throughout the plugin. Can you use an additional admin only field and store the CT001 type number there and always just reference that?

    Posted 9 years ago on Tuesday July 24, 2012 | Permalink
  3. italianbird
    Member

    If I could get it to auto generate, yes. Have any idea how to make that happen?

    Posted 9 years ago on Tuesday July 24, 2012 | Permalink
  4. You can create a function that auto-generates your CT*** number, and store that with the entry. I would use the gform_pre_submission filter. http://www.gravityhelp.com/documentation/page/Gform_pre_submission

    That is called after the form is submitted and all fields are validated, but before the entry is stored. You can generate your number and return it so that it is stored with the entry.

    There are multiple ways to do it. David P posted another possible solution right after I did.

    Posted 9 years ago on Wednesday July 25, 2012 | Permalink
  5. David Peralty

    You would have to create a function. I would create an input field in Gravity Forms called internalID. I would then give it a CSS class of hidden. I would then check off allow populate dynamically. I would give it a parameter name of internalID as well. I would edit my css to have

    .hidden { display:none; }

    You could then using some PHP code create a function to fill this field out automatically. You would have to connect to the database, and check what was the last number assigned, add one to the number and then pre-populate that field with your new value, but coming up with this custom code is beyond the support I can provide here.

    The hook to pre-fill a field is:
    http://www.gravityhelp.com/documentation/page/Gform_pre_render

    So then you would have a number generated based on the last number used, assign the value to a hidden field, and then when you export the data, you could easily sort it by the internalID field.

    Posted 9 years ago on Wednesday July 25, 2012 | Permalink
  6. italianbird
    Member

    Ok, I like where the gform_pre_submission thing is going. I got that working using a hidden field. Now, how can I add (or copy) the entry id# to the field?

    Posted 9 years ago on Wednesday July 25, 2012 | Permalink
  7. What did you store in your hidden field?

    And how do you want to add the entry ID to that? Just append the entry ID to the end of your hidden field?

    Posted 9 years ago on Wednesday July 25, 2012 | Permalink
  8. italianbird
    Member

    The hidden field is rendering CT00... or whatever I want. How do I append the entry ID to the end of the hidden field?

    Posted 9 years ago on Wednesday July 25, 2012 | Permalink
  9. UPDATE 12 September 2012:

    The original post I made here was incorrect. Please see this topic for an updated solution: http://www.gravityhelp.com/forums/topic/entry-ids#post-74963

    Thank you.

    Posted 9 years ago on Wednesday July 25, 2012 | Permalink
  10. italianbird
    Member

    It's probably just me, but the code above isn't working. I can not seem to make the entry ID appear.

    Posted 9 years ago on Thursday July 26, 2012 | Permalink
  11. The code above is not really code; more of an approach on how to do it. Please post your code at pastebin.com or pastie.org in its entirety and we'll take a look at it for you. Please also export your form as XML (Forms menu > Import/Export > "Export Forms" from the top menu) so that we can reference the actual field IDs. Thank you.

    Posted 9 years ago on Thursday July 26, 2012 | Permalink
  12. italianbird
    Member

    I hope I'm replying to your request correctly. Let me know if you need me to reply using a different method(s). Basically, I haven't a clue what to do.
    ===============
    forms_display:

    [php]
    <?php
    add_action("gform_pre_submission", "pre_submission_handler");
    function pre_submission_handler($form){
        $_POST["input_22"] = "CT0";
    }
    ?>
    [php]
    <?php
    // this presumes your CT00... number is stored in field 10 in your form
    // change this if it's not
    $invoiceID = $entry["22"] . $entry_ID;{
    
    // presumes you will store your created ID in field 23
    // change this if not
    $entry["24"] = $invoiceID;
    return $entry;
    }
    ?>

    =================
    xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <forms version="1.6.4.5.4">
    	<form labelPlacement="top_label" useCurrentUserAsAuthor="1">
    		<title><![CDATA[Load Details]]></title>
    		<confirmation type="message">
    			<message><![CDATA[Thank you. Your load details have been submitted.]]></message>
    		</confirmation>
    		<button type="text">
    			<text><![CDATA[Submit]]></text>
    		</button>
    		<fields>
    			<field id="9" isRequired="1" size="medium" type="radio">
    				<label><![CDATA[Who are you?]]></label>
    				<choices>
    					<choice>
    						<text><![CDATA[CT Employee]]></text>
    					</choice>
    					<choice>
    						<text><![CDATA[Broker]]></text>
    					</choice>
    				</choices>
    			</field>
    			<field allowsPrepopulate="1" id="22" size="medium" type="text">
    				<cssClass><![CDATA[hidden]]></cssClass>
    				<inputName><![CDATA[invoiceID]]></inputName>
    				<label><![CDATA[CT Pro Nbr]]></label>
    			</field>
    			<field id="2" size="medium" type="text">
    				<label><![CDATA[Customer Pro Nbr]]></label>
    			</field>
    			<field id="3" isRequired="1" size="medium" type="text">
    				<label><![CDATA[Truck Nbr]]></label>
    			</field>
    			<field id="4" isRequired="1" size="medium" type="name">
    				<label><![CDATA[Driver Name]]></label>
    				<inputs>
    					<input id="4.3">
    						<label><![CDATA[First]]></label>
    					</input>
    					<input id="4.6">
    						<label><![CDATA[Last]]></label>
    					</input>
    				</inputs>
    			</field>
    			<field id="14" size="medium" type="html" displayOnly="1">
    				<content><![CDATA[<hr /></hr>]]></content>
    				<label><![CDATA[HTML Block]]></label>
    			</field>
    			<field id="10" size="medium" type="text">
    				<label><![CDATA[Origin Name]]></label>
    			</field>
    			<field id="11" size="medium" type="address" addressType="us" hideAddress2="1">
    				<label><![CDATA[Origin Address]]></label>
    				<defaultCountry><![CDATA[United States]]></defaultCountry>
    				<defaultState><![CDATA[Tennessee]]></defaultState>
    				<inputs>
    					<input id="11.1">
    						<label><![CDATA[Street Address]]></label>
    					</input>
    					<input id="11.2">
    						<label><![CDATA[Address Line 2]]></label>
    					</input>
    					<input id="11.3">
    						<label><![CDATA[City]]></label>
    					</input>
    					<input id="11.4">
    						<label><![CDATA[State / Province]]></label>
    					</input>
    					<input id="11.5">
    						<label><![CDATA[Zip / Postal Code]]></label>
    					</input>
    					<input id="11.6">
    						<label><![CDATA[Country]]></label>
    					</input>
    				</inputs>
    			</field>
    			<field id="12" size="medium" type="name">
    				<label><![CDATA[Origin Contact]]></label>
    				<inputs>
    					<input id="12.3">
    						<label><![CDATA[First]]></label>
    					</input>
    					<input id="12.6">
    						<label><![CDATA[Last]]></label>
    					</input>
    				</inputs>
    			</field>
    			<field id="20" size="medium" type="phone" phoneFormat="standard">
    				<label><![CDATA[Origin Phone]]></label>
    			</field>
    			<field id="1" size="medium" type="page" displayOnly="1">
    				<nextButton type="text">
    					<text><![CDATA[Next]]></text>
    				</nextButton>
    				<previousButton type="text">
    					<text><![CDATA[Previous]]></text>
    				</previousButton>
    			</field>
    			<field id="16" size="medium" type="text">
    				<label><![CDATA[Destination Name]]></label>
    			</field>
    			<field id="17" size="medium" type="address" addressType="us" hideAddress2="1">
    				<label><![CDATA[Destination Address]]></label>
    				<defaultCountry><![CDATA[United States]]></defaultCountry>
    				<defaultState><![CDATA[Tennessee]]></defaultState>
    				<inputs>
    					<input id="17.1">
    						<label><![CDATA[Street Address]]></label>
    					</input>
    					<input id="17.2">
    						<label><![CDATA[Address Line 2]]></label>
    					</input>
    					<input id="17.3">
    						<label><![CDATA[City]]></label>
    					</input>
    					<input id="17.4">
    						<label><![CDATA[State / Province]]></label>
    					</input>
    					<input id="17.5">
    						<label><![CDATA[Zip / Postal Code]]></label>
    					</input>
    					<input id="17.6">
    						<label><![CDATA[Country]]></label>
    					</input>
    				</inputs>
    			</field>
    			<field id="18" size="medium" type="name">
    				<label><![CDATA[Destination Contact]]></label>
    				<inputs>
    					<input id="18.3">
    						<label><![CDATA[First]]></label>
    					</input>
    					<input id="18.6">
    						<label><![CDATA[Last]]></label>
    					</input>
    				</inputs>
    			</field>
    			<field id="19" size="medium" type="phone" phoneFormat="standard">
    				<label><![CDATA[Destination Phone]]></label>
    			</field>
    			<field id="5" isRequired="1" size="medium" type="date" calendarIconType="none" dateType="datefield">
    				<label><![CDATA[Pickup Date]]></label>
    			</field>
    			<field id="6" size="medium" type="time">
    				<label><![CDATA[Pickup Time]]></label>
    			</field>
    			<field id="7" size="medium" type="date" calendarIconType="none" dateType="datefield">
    				<label><![CDATA[Delivery Date]]></label>
    			</field>
    			<field id="8" size="medium" type="time">
    				<label><![CDATA[Delivery Time]]></label>
    			</field>
    			<field adminOnly="1" id="23" size="medium" type="checkbox">
    				<adminLabel><![CDATA[Approved?]]></adminLabel>
    				<label><![CDATA[Approved? (Admin-only)]]></label>
    				<choices>
    					<choice>
    						<text><![CDATA[Approved]]></text>
    					</choice>
    				</choices>
    				<hideInDirectory><![CDATA[1]]></hideInDirectory>
    				<hideInSingle><![CDATA[1]]></hideInSingle>
    			</field>
    			<field allowsPrepopulate="1" id="24" size="medium" type="text">
    				<inputName><![CDATA[internalID]]></inputName>
    				<label><![CDATA[Untitled]]></label>
    			</field>
    		</fields>
    		<descriptionPlacement><![CDATA[below]]></descriptionPlacement>
    		<lastPageButton type="text">
    			<text><![CDATA[Previous]]></text>
    		</lastPageButton>
    		<pagination type="steps">
    			<pages>
    				<page><![CDATA[Administrative Stuff]]></page>
    				<page><![CDATA[Load Details]]></page>
    			</pages>
    		</pagination>
    		<requireLogin><![CDATA[1]]></requireLogin>
    		<requireLoginMessage><![CDATA[You must be logged in to submit new entries or view records.]]></requireLoginMessage>
    		<notification>
    			<to><![CDATA[donbowins@gmail.com]]></to>
    			<subject><![CDATA[New submission from {form_title}]]></subject>
    			<message><![CDATA[{all_fields}]]></message>
    		</notification>
    	</form>
    </forms>
    Posted 9 years ago on Monday July 30, 2012 | Permalink
  13. Sorry @italianbird, your topic scrolled off the screen and was forgotten. If you still need assistance with this, I posted a solution on this topic: http://www.gravityhelp.com/forums/topic/entry-ids#post-74963

    Posted 9 years ago on Wednesday September 12, 2012 | Permalink