2

I want to dynamically add a new list ("AddList" operation), and then use the SPServices "UpdateList" operation to add "newFields". I was able to get the "Text" fields to add properly, but the LookUp fields are what I'm specifically having trouble with.

Here's my code:

var newListName = "Title" + todaysDate;    
var nfields = "<Fields><Method ID='1'><Field Type='LookUp' List='{4E185F24-9DE1-4E2F-8915-16C28816F102}' ShowField='ID' DisplayName='MatchedEquipmentRecord'></Field></Method>" +
            "<Method ID='2'><Field Type='LookUp' List='"+ listGUID +"' ShowField='ID' DisplayName='OriginalSupplyRecord'></Field></Method>" +
            "<Method ID='3'><Field Type='Text' DisplayName='AccountCustodian' ResultsType='Text'></Field></Method>" + 
            "<Method ID='4'><Field Type='Text' DisplayName='AssetID' ResultsType='Text'></Field></Method>" + 
            "<Method ID='5'><Field Type='Text' DisplayName='SerialNumber' ResultsType='Text'></Field></Method>" + 
            "<Method ID='6'><Field Type='Text' DisplayName='ItemDescription' ResultsType='Text'></Field></Method>" + 
            "<Method ID='7'><Field Type='Text' DisplayName='Brand' ResultsType='Text'></Field></Method>" + 
            "<Method ID='8'><Field Type='Text' DisplayName='ModelNumber' ResultsType='Text'></Field></Method>" + 
          "</Fields>"; 
$().SPServices({ 
    operation: 'UpdateList', 
        listName: newListName, 
        newFields: nfields, 
        completefunc: function(xData, Status) { 
           console.log(xData.responseText);
        }
});

My variables todaysDate and listGUID I've made previously.

When I log the responseText, I get this error message for my Lookup columns:

<ErrorCode>0x80004005</ErrorCode><ErrorText>Operation Failed</ErrorText>

I'm assuming it has to do with the properties in the "Field Type='LookUp'" that is giving me the issue. I've searched all over the internet all morning to try and get the right names for the what I need to reference in the method. But I couldn't find anything that I needed.

Does anyone know what is required to dynamically create a lookup column with SPServices "UpdateList" operation?

0

1 Answer 1

1

Try Type='Lookup' with a lowercase U

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.