Auto assign related items with Safari
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
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:
After saving the form, open it in your browser, open the child form and provide content of the browser console.
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();
}
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
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();
}
Hi Dmitry,
thanks, the parent field is being set properly now.
console log:
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)
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
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.
As I understood, the field is populated properly now, am I right? Just use this workaround for now - it should work in all browsers.
-
- Information
-
Who is online
Users browsing this forum: No registered users and 20 guests