• Resolved josephmarkovich

    (@josephmarkovich)


    If I am passing a GUID in a querystring, how can I use it in a form field to create a new record?

    My scenario is passing a project ID to another page. I want to use that project’s GUID in a form field to create a new record.

    I created the form and set the default value to the GUID from the querystring. When I submit the form, I receive a fatal error.

    It feels like the premium plugin would just handle this for me, but I am working on this as a demo and can’t purchase the plugin just yet.

    Thank you.
    Joe

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author alexacrm

    (@alexacrm)

    use that project’s GUID in a form field to create a new record

    What are you trying to set? A guid of the new record (which is usually not recommended) or a lookup field?

    Thread Starter josephmarkovich

    (@josephmarkovich)

    I am trying to set a lookup field.

    Joe

    Plugin Author alexacrm

    (@alexacrm)

    Hey Joe,

    lookups are EntityReference objects so the value looks like { "LogicalName": "contact", "Id": "00000000-0000-0000-0000-000000000000", "DisplayName" : "Joe" }. For example:

    <input type="hidden" name="foo_project" value='{ "LogicalName": "msdyn_project", "Id": {{params.projectId}} }' />

    Display name isn’t really used to set the value unless you’re setting default for the visual lookup control (that one is in premium addon).

    HTH
    George

    Thread Starter josephmarkovich

    (@josephmarkovich)

    Hi George-

    Thanks for the guidance here. I’ve just been able to get back to this project again.

    These are my two form fields:

    {% form entity="jcma_projectvolunteer" mode="create" %}
    <form>
        <div class="form-group">
            <input type="form-control" name="jcma_project" value='{ "LogicalName": "jcma_projectvolunteer", "Id": {{projectid}} }'>
        </div>
        <div class="form-group">
            <input type="form-control" name="jcma_contact" value='{ "LogicalName": "jcma_projectvolunteer", "Id": {{contactid}} }'>
        </div>
        <div class="form-group">
            <button type="submit" class="btn btn-primary">Join This Project</button>
        </div>
    </form>
    {% endform %}

    When I load the page and look at the two fields, this is what is filled in:

    Project:
    { “LogicalName”: “jcma_projectvolunteer”, “Id”: 9fee4671-5fca-ec11-a7b5-000d3a998753 }

    Contact:
    { “LogicalName”: “jcma_projectvolunteer”, “Id”: 258cc37a-2dd2-ec11-a7b5-0022481ce6f7 }

    When I submit, it gives me this really nasty error:
    Failed to submit the form.
    There has been a critical error on this website.

    How can I look at some error checking or find out what is causing this to fail?

    Thank you.
    Joe

    Plugin Author alexacrm

    (@alexacrm)

    @josephmarkovich

    the values look wrong, LogicalName should be “contact” for one and “msdyn_project” for another one.

    More information is usually available in the debug log (set in plugin configuration)

    Thread Starter josephmarkovich

    (@josephmarkovich)

    Hi George-

    Thanks for the help with that! That was part of it. The other part was the missing quotes around the GUID.

    { "LogicalName": "jcma_project", "Id": "9fee4671-5fca-ec11-a7b5-000d3a998753" }
    { "LogicalName": "contact", "Id": "258cc37a-2dd2-ec11-a7b5-0022481ce6f7" }

    It would help if I had read the documentation closer!
    { "LogicalName": "contact", "Id": "00000000-0000-0000-0000-000000000000" }

    Thank you!
    Joe

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘GUID in querystring to use in form’ is closed to new replies.