Thomas Wolstenholme

Forum Replies Created

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • in reply to: vLookup from New on separate list #12928
    Thomas Wolstenholme
    Participant

    Worked perfectly!

    So simple, thanks Alex – sending you some beers for the great tools you have developed for the world to use and share! Honestly it is brilliant!

    in reply to: Allow certain users to Edit #12926
    Thomas Wolstenholme
    Participant

    Thanks for the reply/help/advice Alex!

    I will be trying it out today so will let you know how I get on. Loving the Lord of the Rings reference though 😉

    Thank you again!

    in reply to: vLookup from New on separate list #12884
    Thomas Wolstenholme
    Participant

    I don’t know if it is the most elegant solution but I managed to get it to work by creating a var for the value I was wanting to grab and then use to lookup the information in the external list (external list refers to the Evaluation list if you are comparing this to the original query)

    var val =  $(fields['BPUID']).find('input').val();

    Full solution is below for reference:

    
    
        $("#BPUID_spjs_lookup").change(function(){
    	var val =  $(fields['BPUID']).find('input').val();
    	
    	var res, qb = [], item;
    	
    	    qb.push("<Where>");
            qb.push("<Eq>");
            qb.push("<FieldRef Name='BP_x0020_UID' LookupId='TRUE' /><Value Type='Text'>"+val+"</Value>");
            qb.push("</Eq>");
            qb.push("</Where>");
    
        	res = spjs_QueryItems({"listName":"Building Demo","query":qb.join(""),"viewFields":["Name1","Site_x002f_Location","Description","OP_x0020_Number"]});
        	console.log(res);
            if(res.count > 0){
                item = res.items[0];
                setFieldValue("Name1",item.Name1 !== null ? item.Name1 : "not set");
                setFieldValue("OP_x0020_Number",item.OP_x0020_Number !== null ? item.OP_x0020_Number : "not set");
                setFieldValue("Site_x002f_Location",item.Site_x002f_Location !== null ? item.Site_x002f_Location : "not set");
                setFieldValue("Description",item.Description !== null ? item.Description : "not set");
            }
        });

    For the hyperlink query I added the below, basically using the same as above but this time creating a variable to store the ID number found in the external list item

    var idNumber = $(fields['ID0']).find('input').val();

    and using this to bolt onto the end of my hyperlink to send the user to the right item to edit.

    document.getElementById("changeControlLink").innerHTML = "<a href='https://demo/Lists/Building%20Demo/EditForm.aspx?ID="+idNumber+"' target='_blank'>Submit a Change</a>";

    However, one thing which is stumping me is that when is DispForm:

    var val =  $(fields['BPUID']).find('input').val();

    returns ‘undefined’ because it becomes read only, so my link doesn’t work as the ID number is not added at the end of the hyperlink.

    Is there any work around for this problem?

    Full code below:

    
    
    	$(function(){
    	var val =  $(fields['BPUID']).find('input').val();
    	
    	var res, qb = [], item;
    	
    	qb.push("<Where>");
            qb.push("<Eq>");
            qb.push("<FieldRef Name='BP_x0020_UID' LookupId='TRUE' /><Value Type='Text'>"+val+"</Value>");
            qb.push("</Eq>");
            qb.push("</Where>");
    
        	res = spjs_QueryItems({"listName":"Building Demo","query":qb.join(""),"viewFields":["ID"]});
    
        	if(res.count > 0){
                item = res.items[0];
                setFieldValue("ID0",item.ID !== null ? item.ID : "not set");
            }
            
            var idNumber = $(fields['ID0']).find('input').val();
        	
        	document.getElementById("changeControlLink").innerHTML = "<a href='https://demo/Lists/Building%20Demo/EditForm.aspx?ID="+idNumber+"' target='_blank'>Submit a Change</a>";
    
        });
    in reply to: vLookup from New on separate list #12874
    Thomas Wolstenholme
    Participant

    Hi Alexander,

    Massive fan of what you have built and cannot thank you enough!

    I am trying to implement this but I am not getting any values to return.

    I think it is because of this: <Value Type=’Integer’><UserID/></Value>”

    I am trying to match the Employee field (which is a dropdown with lookup values) in the Evaluation List to the same value in the Employee column in the Employee List. How would I get this user selected value to compare to the Employee column?

    Also, I would like one of the returned values to be a hyperlink to edit the line item in the Employee List, is this possible?

    Something like:
    setFieldValue(“Hyperlink”,item.Hyperlink!== null ? item.Hyperlink: “not set”);

    Thank you in advance!

    • This reply was modified 7 years, 7 months ago by Thomas Wolstenholme. Reason: additional query
Viewing 4 posts - 1 through 4 (of 4 total)