Page 1 of 1

Get data from another list in the new form

Posted: 01 Sep 2015
by SPTech
Hi,

We have two different lists, one of them is for employee data. It is holding employee information and number of leave of absence days of each employee. The other list is for leave of absence request. An employee creates a leave of absence request from new form. What we need is to show how many leave of absence days left for the employee who is creating the request in the new form. We tried to get current login name and use it with related items to get data from the employee data list but it is not feasible as we just need one column value and show it in a plain text control. We really stuck at this point and any help will be appreciated.

Re: Get data from another list in the new form

Posted: 01 Sep 2015
by Dmitry Kozlov
Hi Dmitry,

Thank you for the reply.

Is this way a little unsafe ? I mean code will work on client side and if a user try to intercept and change the username variable before sending it to server then it will be possible to get other user's data ?

Re: Get data from another list in the new form

Posted: 01 Sep 2015
by SPTech
If you're using a User or Group column, we can filter the 'Employee' list by the current user without passing his login. CAML-queries support [Me] token:

https://christopherclementen.wordpress. ... aml-query/

Re: Get data from another list in the new form

Posted: 01 Sep 2015
by Dmitry Kozlov
Hi

What you'd need to do is use JavaScript to:

Load the current user's login or name (depending on how you will identify him in the list) using SP.ClientContext, see this post http://sharepoint.stackexchange.com/a/120503
Then using this name you'll load the list, see https://msdn.microsoft.com/en-us/librar ... e.14).aspx. You can specify the user login/name here in CAMLQuery
Then you'll retrieve the required item from the listcollection object https://msdn.microsoft.com/en-us/librar ... 46453.aspx and get the item's property that you need.

Our support team can help you with this task, it will take 100 support minutes. If you're interested, please, pay for the support minutes in our store and send templates of both lists to support@spform.com. To get the templates, please, go to the List Settings -> Save list as template. We will start working on the task the next day after the payment.

Re: Get data from another list in the new form

Posted: 03 Sep 2015
by SPTech
Thank you very much Dmitry, I have successfully completed the development using the sources you provided.