Auto assign related items with Safari

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

21 Aug 2018

May I ask you to add some tracing to the code to find out where the script stops working in Safari. Please, replace you code with:

Code: Select all

if (window != window.top && window.top.fd) {
    console.log('This is a child form');

    // the form is opened in a dialog from the parent form
    var parentId = window.top.GetUrlKeyValue('ID');
    console.log('Parent ID: ' + parentId);
    
    if (parentId) {
        // the form is opened from the Edit form
        fd.field('AssignedTicket').value(parentId);
        
        console.log('AssignedTicket: ' + fd.field('AssignedTicket').value());
    } else {
        // the form is opened from the New form
        $('#_fd_parent_temp > input').val(window.top.fd._tempParentId());
    }
     
    $('.parent-ticket').hide();
}
After saving the form, open it in your browser, open the child form and provide content of the browser console.

Alex
Posts: 32
Joined: Fri Jun 30, 2017

23 Aug 2018

Yes, sure, please find a screenshot attached.
Attachments
Screen Shot 2018-08-23 at 10.28.49.png
Screen Shot 2018-08-23 at 10.28.49.png (142.02 KiB) Viewed 2176 times

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

23 Aug 2018

Thanks, Alex. Please, try the code below:

Code: Select all

if (window != window.top && window.top.fd) {
    console.log('This is a child form');

    // the form is opened in a dialog from the parent form
    var parentId = window.top.GetUrlKeyValue('ID');
    console.log('Parent ID: ' + parentId);
    
    if (parentId) {
        // the form is opened from the Edit form
        fd.field('AssignedTicket').control()._el().find('option').each(function(){
            console.log($(this).val());
            if ($(this).val() == parentId) {
                $(this).prop('selected', 'selected');
                console.log('Parent is found');
            }
        });
        
        console.log('AssignedTicket: ' + fd.field('AssignedTicket').value());
    } else {
        // the form is opened from the New form
        $('#_fd_parent_temp > input').val(window.top.fd._tempParentId());
    }
     
    $('.parent-ticket').hide();
}

Alex
Posts: 32
Joined: Fri Jun 30, 2017

24 Aug 2018

Hi Dmitry,
thanks, the parent field is being set properly now.
console log:

Code: Select all

[Log] This is a child form (fd_CSM Comment_NewForm.aspx, line 573)
[Log] Parent ID: 21 (fd_CSM Comment_NewForm.aspx, line 577)
[Log] 0 (fd_CSM Comment_NewForm.aspx, line 582)
[Log] 1 (fd_CSM Comment_NewForm.aspx, line 582)
[Log] 2 (fd_CSM Comment_NewForm.aspx, line 582)
[Log] 3 (fd_CSM Comment_NewForm.aspx, line 582)
[Log] 4 (fd_CSM Comment_NewForm.aspx, line 582)
[Log] 5 (fd_CSM Comment_NewForm.aspx, line 582)
[Log] 6 (fd_CSM Comment_NewForm.aspx, line 582)
[Log] 7 (fd_CSM Comment_NewForm.aspx, line 582)
[Log] 8 (fd_CSM Comment_NewForm.aspx, line 582)
[Log] 9 (fd_CSM Comment_NewForm.aspx, line 582)
[Log] 10 (fd_CSM Comment_NewForm.aspx, line 582)
[Log] 11 (fd_CSM Comment_NewForm.aspx, line 582)
[Log] 12 (fd_CSM Comment_NewForm.aspx, line 582)
[Log] 13 (fd_CSM Comment_NewForm.aspx, line 582)
[Log] 14 (fd_CSM Comment_NewForm.aspx, line 582)
[Log] 15 (fd_CSM Comment_NewForm.aspx, line 582)
[Log] 16 (fd_CSM Comment_NewForm.aspx, line 582)
[Log] 17 (fd_CSM Comment_NewForm.aspx, line 582)
[Log] 18 (fd_CSM Comment_NewForm.aspx, line 582)
[Log] 19 (fd_CSM Comment_NewForm.aspx, line 582)
[Log] 20 (fd_CSM Comment_NewForm.aspx, line 582)
[Log] 21 (fd_CSM Comment_NewForm.aspx, line 582)
[Log] Parent is found (fd_CSM Comment_NewForm.aspx, line 585)
[Log] 22 (fd_CSM Comment_NewForm.aspx, line 582)
[Log] 23 (fd_CSM Comment_NewForm.aspx, line 582)
[Log] 24 (fd_CSM Comment_NewForm.aspx, line 582)
[Log] 25 (fd_CSM Comment_NewForm.aspx, line 582)
[Log] AssignedTicket: 21 (fd_CSM Comment_NewForm.aspx, line 589)

Alex
Posts: 32
Joined: Fri Jun 30, 2017

28 Aug 2018

any news on this?

Alex
Posts: 32
Joined: Fri Jun 30, 2017

04 Sep 2018

Hi Dmitry
Is there something you can fix within the spform libraries or do I have to use this workaround ?

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

04 Sep 2018

Hi Alex,
As I understood, the field is populated properly now, am I right? Just use this workaround for now - it should work in all browsers.

Alex
Posts: 32
Joined: Fri Jun 30, 2017

04 Sep 2018

yes, ok, thank you

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 28 guests