how can I add new Item with 2 parentID

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
wdksa1
Posts: 7
Joined: Sun Mar 16, 2014

16 Mar 2014

Hello ..


I have 3 list .. agremnt , LIC and Invice ..


I want to link Invoice with the agremnt and LIC list ..


I try to use this :


http://spform.com/office-365/crea ... office-365


but I have 2 field that I need to link it one from LIC and the other from agremnt ..


I try to use it like this :



var licID = fd.getSourceID();if (licID) { fd.field('licID').control().value(licID); $('.licIDhid').hide();}

var agremntID = fd.getSourceID();if (agremntID) { fd.field('agremntID').control().value(agremntID); $('.agremntIDh').hide();}

but it faild !
It shows the same ID for both feild agremnt and lic ..


thank you .. :)

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

17 Mar 2014

Hello,

Thank you for your request. You cannot pass additional arguments from the parent form. But you can query field values from the parent form if you open the child form in a dialog. Put the following code into the child form via JS-editor of Forms Designer.

Code: Select all

if (window.top != window.self){
    alert(window.top.fd.field('Title').value());
}

wdksa1
Posts: 7
Joined: Sun Mar 16, 2014

17 Mar 2014

I got an alert which say "undefined"

I was doing the Idea before by using JavaScript .. this is the code :


<input id="btnGetLookUp" onclick="getLookUp()" type="button" value="add new invoce" />


<script src="http://ajax.aspnetcdn.com/ajax/jquery/j ... "></script>

<script language="ecmascript" type="text/ecmascript">


var listItem;

var list;

var clientContext;


function getLookUp() {


var SelectedID = getParameterByName("ID");

this.clientContext = SP.ClientContext.get_current();

if (this.clientContext != undefined && clientContext != null) {

var webSite = clientContext.get_web();




// ((1)) here change the list name

this.list = webSite.get_lists().getByTitle("lic");

this.listItem = list.getItemById(SelectedID);

clientContext.load(this.listItem);

this.clientContext.executeQueryAsync(Function.createDelegate(this, this.OnLoadSuccess), Function.createDelegate(this, this.OnLoadFailed));

}



}


function OnLoadSuccess(sender, args) {



// ((2)) here change the Item name you need to add it to the URL

var lookup = this.listItem.get_item("agremntID");

var SelectedID2 = getParameterByName("ID");



// ((3)) here change the URL to the new form.

var newItemLink1 = 'http://domain.org/property/Lists/lic_fi ... spx?LicID=' + SelectedID2 + '&agremntID=' + lookup.get_lookupId();

window.open(newItemLink1,"_self");


}



function OnLoadFailed(sender, args) {


alert('Request failed. contact Admin ' + args.get_message() + '\n' + args.get_stackTrace());


}


function getParameterByName(name)

{

name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");

var regexS = "[\\?&]" + name + "=([^&#]*)";

var regex = new RegExp(regexS);

var results = regex.exec(window.location.href);

if(results == null)

return "";

else

return decodeURIComponent(results[1].replace(/\+/g, " "));

}


</script>

but when I use this code with forms designer it doesn't work how can I use your code and what can I do ? thank you ..:)

wdeffner
Posts: 30
Joined: Thu Sep 22, 2016

17 Mar 2014

This is my issue :

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

17 Mar 2014

Do you open license and invoice forms in dialogs? If so, please, use the following code to get ID of agreement:

Code: Select all

alert(window.top.GetUrlKeyValue('ID'));

wdksa1
Posts: 7
Joined: Sun Mar 16, 2014

18 Mar 2014

could you please explain with a little details because I don't understand where can I put this code and how can I get the two ID lic and agreement ?

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

18 Mar 2014

Use this code in the invoice form. So, to get the license ID, you will use:

Code: Select all

var licID = fd.getSourceID();
And to get the agreement ID, please, use the following line:

Code: Select all

var agremntID = window.top.GetUrlKeyValue('ID')

wdksa1
Posts: 7
Joined: Sun Mar 16, 2014

18 Mar 2014

Thank you verry much MR.Dmitry Kozlov .. but may I didn't get it .. Should I open license from agremnt form ? becouse the user on my sharepoint open license from license list so is this the problem ? I try to put the last 2 codes on Js-editor on invoice form but it doesn't get any ID .. so should I make the user go to agremnt then to lic after that to invoce form ?

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

19 Mar 2014

Ok, if users create new invoices from a license form, you can use window.top.fd object to get field values of the parent form: window.top.fd.field('Agreement').value()

wdksa1
Posts: 7
Joined: Sun Mar 16, 2014

19 Mar 2014

Dear Demitry,

I think we still have misunderstanding. I tried the last function too, but still I face the same problem.

Let's me explain that to you again. I have agreement list which is parent list and I have license list which child of agreement list. then I have an invoice list which is child for both agreement and license lists. Both agreement list and license list are an lookup columns in invoice list. I want to shows the agreement ID field and license ID field (which they are lookup columns) in the Invoice list. so, Each license just have only one agreement and I want to get some fields from agreement list and license lists.

Wish this details can help you more for my issue.

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 9 guests