1

This may be a stupid question - sorry if so. I am writing an API function to create a new case, and I want it to pre-fill the New Case form with field contents based the case source contact and two or three parameters obtained from the user. Of course I could create a new form in order to collect the user input before displaying the New Case form, but I wondered if there is a way that the API function can interrogate the user in real time to obtain the input parameters? Thanks.

1

I'm assuming you're on Joomla otherwise I'd say try civicrm webform. One option is define custom fields for cases and then use them during hook_civicrm_postProcess. Another is to add some javascript/jquery to the form via hook_civicrm_buildForm or .extra.tpl to pop up a dialog box to get the input, but that seems awkward - your original idea of having another form that comes before seems better.

0

API functions can be called in different contexts (eg via API Explorer, command line, in extension code etc) so prompting for user input is not practical but they can require specific parameters. You could write your API function to require parameters and then figure out how you're going to get the parameters from the user.

That said, I'm not sure an API function is really what you need here. hook_civicrm_buildForm to add extra bits to the new case form, and hook_civicrm_postProcess for processing the form when it is submitted may be enough.

  • Thanks. Yes, I was hoping to write an API function so I could call the same function from different places, such as a CiviCRM menu and an external script. But it's looking like the form hooks may be the way to go. – Jern Mar 5 at 11:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.