Prepopulating Casetracker
The Prepopulate module for Drupal is a nifty little tool that resets the default values of forms on their way to the browser. This is particularly useful for crafting links to create nodes with pre-set values. You can even prepopulate Case Tracker form values to help users create cases filled out as you would like.
This mechanism is entirely dependent on the URL your users click. Be prepared to replace children in the Create Content menu or even create a custom module and hook_form_alter links around your site if you want these changes to approach universal use.
The Basics
First off, know your URL. We will be adding a query string to the url node/add/casetracker-basic-case
If you want, you can imagine it starts off with http://www.example.com/ but Drupal can take care of that.
To set a default title, you need to add a bit of a query string: ?edit[title]=New Case Title.
Our URL now looks like:node/add/casetracker-basic-case?edit[title]=New Case Title
We can also modify the body:node/add/casetracker-basic-case?edit[title]=New Case Title&edit[body_field][body]=This is a prepopulate-created case.
Or perhaps add a few taxonomy tags (tagging vocabularies only):node/add/casetracker-basic-case?edit[taxonomy][tags][]=casetracker, drupal, prepopulate
What is the VID?
The Vocabulary ID can be found at your admin/content/taxonomy page. Look at the number at the end of the Edit Vocabulary link next to each vocabulary.
Case Tracker Values
Now that we understand the basic idea of how this works, we will run through the various Case Tracker-specific fields.
Project
To specify the project your new case will be associated with, you need to know the Node ID of the Project. To get a quick list of all the project IDs, you can view source on the node/add/casetracker-basic-case page and the select drop-down for projects will list the nid’s in the value attribute of each option.
node/add/casetracker-basic-case?edit[casetracker][pid]=2
Assigned User
The assigned users are specified by username. Remember, not just any user can be assigned tickets, only those that can access the case tracker.
node/add/casetracker-basic-case?edit[casetracker][assign_to]=workerbee
Status, Priority, & Type
The “state” information of your case is a little more difficult to determine. I suggest you return to the View Source trick from the Project section, as you need the id codes for each status, priority, and type value.
For this example, Status “Postponed” is 6, Priority “Critical” is 14, and Type “General Task” is 11.
node/add/casetracker-basic-case?edit[casetracker][case_status_id]=6&edit[casetracker][case_type_id]=11&edit[casetracker][case_priority_id]=14
How Do I Prepopulate Other Fields?
If you want to learn more about the Prepopulate module, take a look at it’s Handbook Page. Even better (and more current) are the Usage Notes packaged in the module release in USAGE.txt?revision=1.5&view=markup">USAGE.txt.
The most important thing to realize is that Prepopulate knows how to read the Forms API and uses that insight to replace the #default_value of each specified HTML field.
Terms: drupalcasetrackerprepopulate