Page 1 of 2

Auto assign related items with Safari

Posted: 13 Aug 2018
by Alex
I have issues to "auto assign" related items to a parent item using Safari.

The child item form is opening as a Pop Up over the parent item. The related pop up stays empty.

Any ideas what to consider using Safari?

regards
Alex

Re: Auto assign related items with Safari

Posted: 13 Aug 2018
by Nikita Kurguzov
Dear Alex,
Not sure if there is an issue with Safari specifically, but when you create Child from the New Form - there is no way to populate Parent Field directly (there is no ID yet), so it populates hidden field instead, and then during saving it will link the items together.

Here's a video example - https://www.youtube.com/watch?v=rd8g6Zu1H_E

Re: Auto assign related items with Safari

Posted: 13 Aug 2018
by Alex
Hi Nikita,

the parent item is already there. I'm trying to create an new child item from the parent "View" form.

Re: Auto assign related items with Safari

Posted: 13 Aug 2018
by Nikita Kurguzov
Dear Alex,
Are you sure the issue is with the Safari browser? Does it work with Google Chrome for example?

Re: Auto assign related items with Safari

Posted: 13 Aug 2018
by Alex
Yes, I tested it on Win10 with Edge, Chrome, Opera and Firefox
Even on MAC it is working well with Firefox....

Seems that Safari has an issue with it.

Re: Auto assign related items with Safari

Posted: 14 Aug 2018
by Alex
@Nikita were you able to reproduce it?

Re: Auto assign related items with Safari

Posted: 14 Aug 2018
by Nikita Kurguzov
Dear Alex,
Unfortunately not. Can you, please, try to open the Edit form in Safari, try to add an item, and open browser's console? There should be an error related to the problem, please, send us a screenshot of the error, if it is there.

Re: Auto assign related items with Safari

Posted: 20 Aug 2018
by Alex
Hi Nikita,
I tried display form and edit form, there is only sometimes a error on the edit form (see 2nd screen shot).

any ideas?
It would be possible to create a similar site for you, probably would be more helpful?

br, Alex

Re: Auto assign related items with Safari

Posted: 20 Aug 2018
by Dmitry Kozlov
Hi Alex,
Could you provide your code from the child form?

Re: Auto assign related items with Safari

Posted: 21 Aug 2018
by Alex
Hi Dmitry,
yes, I have this inside the JavaScript Editor

Code: Select all

if (window != window.top && window.top.fd) {
    // the form is opened in a dialog from the parent form
    var parentId = window.top.GetUrlKeyValue('ID');
    if (parentId) {
        // the form is opened from the Edit form
        fd.field('AssignedTicket').value(parentId);
    } else {
        // the form is opened from the New form
        $('#_fd_parent_temp > input').val(window.top.fd._tempParentId());
    }
     
    $('.parent-ticket').hide();
}
and additional JS code via linked script:

Code: Select all

if (typeof jQuery == "undefined") {
    jQuery = Plumsail.FD.jQuery;
}
window.TicketPartnerID = ((_spPageContextInfo.webAbsoluteUrl).replace(_spPageContextInfo.siteAbsoluteUrl, "")).replace(/\D/g, '');
var success = false;
jQuery(document).ready(function () {
    fd.onsubmit(function () {
        var postURL = "https://prod-16.westeurope.logic.azure.com:443/workflows/xxxxxxxxxx/triggers/manual/paths/invoke?api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=yyyyyyyyyyyyy";
        var data = JSON.parse('{"partnerID":"' + parseInt(window.TicketPartnerID) + '","ticketID":"' + window.top.GetUrlKeyValue('ID') + '","title":"' + fd.field("Title").value() + '","author":"' + _spPageContextInfo.userDisplayName + '","userId":"'+_spPageContextInfo.userId+'"}');
        if (!success) {
            jQuery.ajax({
                url: postURL,
                method: "POST",
                headers: {
                    "Accept": "application/json",
                    "Content-Type": "application/json"
                },
                data: JSON.stringify(data),
                success: function () {
                    console.log("azure call successful.");
                    success = true;
                    fd.save().click();
                }
            });
        }
        if (success) {
            return true;
        }

        return false;
    });

});