I'm trying to create a new lookup table in Project Server 2016 on prem from a SP hosted application using JSOM.
I have the following code:
private createLookupTables(): ng.IPromise<any> {
var deferred = this.$q.defer();
var projectContext = PS.ProjectContext.get_current();
var lookupTables = projectContext.get_lookupTables();
projectContext.load(lookupTables);
projectContext.executeQueryAsync((sender, args) => {
lookupTables.add(this.createLookupTable('54085ae0-d844-4c50-8835-c07e069cace2', 'test29'));
lookupTables.update();
projectContext.load(lookupTables);
projectContext.executeQueryAsync((sender, args) => {
deferred.resolve();
}, (sender, args) => {
deferred.reject(args.get_message());
});
}, (sender, args) => {
deferred.reject(args.get_message());
});
return deferred.promise;
}
private createLookupTable(id: string, name: string): any {
var lookupTableCreationInfo = new PS.LookupTableCreationInformation()
lookupTableCreationInfo.set_id(id);
lookupTableCreationInfo.set_name(name);
lookupTableCreationInfo.set_sortOrder(0);
var lookupMask = new PS.LookupMask();
lookupMask.set_length(0);
lookupMask.set_maskType(3);
lookupMask.set_separator('.');
lookupTableCreationInfo.set_masks(lookupMask);
var entries = [];
var ltEntry = new PS.LookupEntryCreationInformation();
ltEntry.set_description("descr");
ltEntry.set_sortIndex(1);
ltEntry.set_id("7a6a9f6c-0987-4e72-887a-7cee1fdf9809")
ltEntry.set_parentId(null);
var ltValue = new PS.LookupEntryValue();
ltValue.set_textValue("test");
ltEntry.set_value(ltValue);
entries.push(ltEntry);
lookupTableCreationInfo.set_entries(entries);
return lookupTableCreationInfo;
}
What am I missing or doing wrong? Currently, the second executeQueryAsync call goes on the fail function with the error message being "Unknown error". Any ideas?