fd.field().value() not working

rss

Posted by Felix Müller - Jan 29 ’15 at 03:38

Hi,

I have a form with an lookupfield called Ticket. I try to set die lookupfield with javascript with the help of a url parameter. My javascrpt is the following:

//check if my custom parameter ParentID is set
var parentID = 5;
if (parentID) {
//parentID is set
var ret = fd.field('Ticket').value(parentID);
//check if the setting was succesful
if (parentID == ret.value()) {
$('.ticket-field').hide();
} else {
alert(parentID + " - " + ret.value());
}
}

When I open the form with following url (ie. from a related item list) the ticket field is succesfully set:

http://server/Lists/Ticketaufgaben/fd_Ticketaufgabe_New.aspx?List=bc699854%2D611e%2D4492%2Db4ef%2D1519df87e38a&RootFolder=&Web=eaeabd0d%2D3e20%2D4f39%2Db9be%2Dc0bbb806a8d9&Source=http%3A%2F%2Fserver%2FLists%2FTickets%2Ffd_Ticket_1aa4835b-81a8-4e10-9257-0b3ebfbe675f_Display.aspx%3FList%3D92292e27-9d1b-4707-8cda-d6fcb607d26e%26ID%3D5

When I open the form with following url (ie. from a user defined action) the alert box is telling me that setting the value was not successfull.

http://server/Lists/Ticketaufgaben/fd_Ticketaufgabe_New.aspx?List=bc699854%2D611e%2D4492%2Db4ef%2D1519df87e38a&RootFolder=&Web=eaeabd0d%2D3e20%2D4f39%2Db9be%2Dc0bbb806a8d9&Source=http%3A%2F%2Fserver%2FLists%2FTickets%2Ffd_Ticket_1aa4835b-81a8-4e10-9257-0b3ebfbe675f_Display.aspx%3FList%3D92292e27-9d1b-4707-8cda-d6fcb607d26e

The only difference between the two URL is the ID parameter in the source parameter.

I see no reason thy it is necessary to have an ID parameter in the source paramter just to do the fd.field('Ticket').value(parentID);

Can you tell me what I did wrong?

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 8 years 2 months 15 days
    #1 by Dmitry Kozlov Jan 29 ’15 at 10:42

    Hi,

    I cannot find where you retrieve a query parameter in your code. Please, make sure that the source code of your form page contains the JavaScript you've published here. Most likely that you use fd.getSourceID function to get the parent ID because it extracts ID of the parent item from the Source parameter of the query string.

  • Felix Müller
    Member
    Member for: 7 years 8 months 26 days
    #2 by Felix Müller Jan 29 ’15 at 11:56

    Hi Dmitry,

    I simplyfied the code to point the finger to the problem. In my demo code I set the variable statically to 5 which is a valid ID in my testsystem. When I open the form containing exactly the code above with the URLs mentioned above I can see the described behavior.

    The problem seems to be that the value() method somehow runs into an error, when the ID parameter is missing in the source parameter.

     

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 8 years 2 months 15 days
    #3 by Dmitry Kozlov Jan 30 ’15 at 02:46

    [#2]: Could you send HTML-source of your form page to [email protected]?

Displaying 1 to 3 of 3 messages