SharePoint 2013 Survey field ID generates dynamic and doesnt fire

Shri-6058 326 Reputation points
2020-10-29T08:21:32.037+00:00

Hello,

I was trying to autopopulate using Jquery using webservice and I am able to populate with my Id and farm admin accounts and a few other accounts. However when I checked with a few users, they were not able to generate auto populate. I found out the Survey list field control Id generates different for some set of users. Will you please let me know how to get the accurate sharepoint survey field control Id for all users?

Initially I tried sharepoint internal names, since I am having several hidden fields, its not working., I then tried using Javascript document.getElementById results undefined. Finally in my code I used #ctl00_ctl43_g_12456cdb_b65e_4696_b128_279228526bfe_ctl00_ctl02_ctl00_ctl00_ctl00_ctl04_ctl00_ctl00_TextField control for autopopulate and its working just fine for me and a set of users but in some other set of users, the code is #ctl00_ctl44_g_12456cdb_b65e_4696_b128_279228526bfe_ctl00_ctl02_ctl00_ctl00_ctl00_ctl04_ctl00_ctl00_TextField(different) causing not to auto populate. Will you please advise on collecting the correct control Id for all users?

SharePoint Server
SharePoint Server
A family of Microsoft on-premises document management and storage systems.
2,297 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,270 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Amos Wu-MSFT 4,051 Reputation points
    2020-10-30T02:14:02.987+00:00

    You could try to use jQuery attribute selector.jQuery selector can automatically match elements that meet the requirements of the selector.
    jQuery attribute selector document
    Example:

        $("input[id*='TextField'][title='question display name']")  
        or $("input[title='question display name']")  
        or $("[id*='TextField'][title='question display name']")  
    

    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.