Pre-filling user's phone number

2 コメント

  • Karen Snyder
    Community Moderator

    Hi Robert,

    You can call an API to get the current user data, which contains the user phone number; of course, if the phone number is not set in the user data then your custom field value won't change.

    The following code should work in script.js, assuming that the custom field ID is correct. Make sure you put the code inside the document.ready function.

    $.getJSON('/api/v2/users/me.json', function () {

    })
    .done(function(data) {
        $("#request_custom_fields_123")[0].value = data.user.phone;
    });

    Please let me know if you have any problems.

    By the way, according to this information about the user phone number, it may be stored in a format like +15551234567, which you might want to format with parentheses and hyphens.

     

     

     

    0
  • Robert

    Thank you Karen! It worked like a charm.

    0

サインインしてコメントを残してください。

Powered by Zendesk