Looking up the SP.FieldLookupValue with result from javascrip
Overview: I have a master form with a list of Project eg. Project 101- Building the Bridge.
However, the project is broken down in 3 sub components. eg. Project 101.01 - Plan of Bridge, Project 101.02 - Design of Bridge, Project 101.03 - Build the bridge.
List 1 - is the Parent Project -with fields including project name, project owner, project supervisor, project budget.
List 2 - is the project sub components - with similar field, but project owner may need to be changed at the time of creating the project sub component.
Here is where I need to have a solution that can read the values from the Project Master (List 1) and display these into the New Form during the creation of the Project Sub Component.
I have searched and here is reference that is found in console.log when i pull the record using a CAML Query.
I return value such as X which is an object.
Console.log(x) outputs
What I want to get is the value for the Mr. John Public.
What I did thus far is as follows:
Pull the value using CAML and assign the object to x
var x = CAML query which returns the object for the Project manger, because this is a lookup sharepoint field from the SP user groups. (pelase note this happend for any list field in SP)
// I create an object of the type SP.FieldUserValue();
var object = new SP.FieldUserValue();
\\ Assign X to this obejct.
object =x;
Then get the lookupValue() - here you can get the ID if you wish and use other fancy codes do more.
var IDX=object.get_lookupValue();
console.log(IDX);
return IDX;
-
Official comment
Hi Imi Chitterman,
I suppose you have a Dossier for this structure, where the sub components list is connected to the projects list with a lookup. Like this it is even easier to get values from the parent element through this lookup instead of querying the list.
You can use Initial and calculated expression (if the project is changed later on the form) for this. I've created a quick tutorial video to show you how I do it:
Is this what you are looking for?
BR Matthias
-
Thanks.
This worked when we have sublist. In cases where two list are different it will not work. I believe this is instructive to help ensure the best structure is used when starting a project.
0
Please sign in to leave a comment.
Comments
2 comments