Get SharePoint item from document library based on custom metadata - sharepoint

I am storing metadata with my documents and folders in SharePoint. This metadata includes an itemid which is a unique identifier from the system it came from. Is there a way to retrieve the item from SharePoint using Graph API by specifying the itemid in the metadata?
This query works for properties that Microsoft provides like name:
https://graph.microsoft.com/v1.0/sites/{siteid}/drive/root/children?$filter=name eq 'Z'
But if I try it with the custom property then I simply get an empty result:
https://graph.microsoft.com/v1.0/sites/{siteid}/drive/root/children?$filter=itemid eq 'Z'
Is there a way to query documents and folders with custom properties like this?
Here is the code used to update the field on the document in SharePoint using Graph API:
public FieldValueSet UpdateListItem(string siteId, string driveId, string fileItemId, Dictionary<string, object> additionalData)
{
var updateFileTagsRequest = graphClient.Sites[siteId].Drives[driveId].Items[fileItemId].ListItem.Fields.Request();
var fieldValueSet = new FieldValueSet { AdditionalData = additionalData };
var result = updateFileTagsRequest.UpdateAsync(fieldValueSet).Result;
return result;
}
The dictionary values being passed to the UpdateListItem method are strings and look like this: "ItemId", "A unique value"

Related

AutoMapper - Retrieve a different field from a linked source table than the one that links it

I have the following table structure that mixes legacy fields with an updated schema:
Coaster
Id (Int)
ParkId (Int)
Park
Id (int)
UniqueId (Guid)
So, the Coaster and Park tables are linked using the Park.Id field. The UniqueId field is not currently used in the old schema. We are migrating to a clean DB using AutoMapper, and this new schema looks like this:
Coaster
Id (Int)
ParkId (Guid)
Park
Id (Guid)
The problem I am having is doing this using AutoMapper. I've been experimenting with this code:
private ModelMapper()
{
Mapper.Initialize(x =>
{
x.AddProfile<ConvertersMappingProfile>();
});
}
// This is the part that I'm trying to work out
public ConvertersMappingProfile()
{
CreateMap<Park, NewSchema.Park>()
.ForMember(dst => dst.Id, map => map.MapFrom(src => src.ParkId));
}
In the new schema, the Park table's Id matches the old schema's UniqueId.
My question is: Because in the old schema there is no direct link to the UniqueId value of the Park table, how to do I get that value to map to the new schema using the Coaster.ParkId field to Park.Id field mapping?
I used a custom resolve to fix the problem. So I created my resolver, which pulls up a list of the items in the database (which is typically pretty small) to get all the values from the table I need, and retrieves the value. (Pre-refactored code):
public class ParkResolver : IValueResolver<Original.Park, New.Park, string> {
public string Resolve(Original.Park source, New.Park dest, string destMember, ResolutionContext context) {
List<Original.Park> list = new List<Original.Park>();
using (IDbConnection con = new SQLiteConnection(#"Data Source=C:\Users\Me\Documents\Parks.sql;")) {
con.Open();
list = con.Query<Original.Park>($"SELECT * FROM Parks WHERE Id = {source.ParkId}").ToList();
con.Close();
}
return list.FirstOrDefault().UniqueId;
}
}
And I call my custom resolver for the tables I am mapping:
CreateMap<Original.Park, New.Park>()
.ForMember(dst => dst.ParkId, map => map.MapFrom(new ParkResolver()));
Hopefully that will help someone else.

Record Id and Type coming as null when I get the result from a saved search in a suitscript

I have a saved search already in my sandbox account.I am not sure on what record the saved search is created. I tried loading the saved search as :
var savedSearch = nlapiLoadSearch("item", searchId);
var resultset = savedSearch.runSearch();
resultset.getResults(0, 1000);//Actually I have looped and got all my search results.
When I run it on the debugger I get to see the results in the columns correctly, but I see the recordId and recordType of the savedsearch result is null. I want to have the recordtype, so that I can load that particular record as required.
Attached is a screenshot of the debugger results in variables section.
If the methods Eric mentions are returning nulls the your search is probably using aggregates like count and sum.
You can get internal id by including internal id as a group field and you can include type as a group field too but you can't use it directly like you can results[i].getRecordType()
nlobjSearchResult Objects have getId() and getRecordType() methods for this purpose.
For example, if you store your results in an Array called searchResults:
searchResults.forEach(printResult);
function printResult(result) {
var recordId = result.getId();
var recordType = result.getRecordType();
// ...
}

Azure Search not returning document ID

Im using azure search. I have my id field set as retrievable yet its not getting returned in my search results. Do you guys know why? I only see: document object -> key value, in the search result of an individual document. (Im using the .net SDK)
I want this ID to do a document lookup and serve the real document to the consumer.
public static DocumentSearchResult GetSearchResult(ISearchIndexClient indexClient, string searchTerm)
{
SearchParameters parameters;
DocumentSearchResult results;
parameters =
new SearchParameters()
{
Select = new[] { "content" }
};
results = indexClient.Documents.Search(searchTerm, parameters);
return results;
}
I found out that i could put ID in searchparameters to retrieve it. This feels unnatural though..
I found out that i could put ID in searchparameters to retrieve it.
parameters =
new SearchParameters()
{
Select = new[] { "content", "id" }
};
As a side note: to serve the document to the caller you need to add the metadata_storage_path to the index (and to the searchparameters to retrieve it as a searchresult)!
https://learn.microsoft.com/en-us/azure/search/search-howto-indexing-azure-blob-storage

NetSuite Suite script - all columns for object

Is there a function in Suitescript using which we would get all the fields or columns belonging to the object (i.e. location, account, transaction etc.)
You can use the function getAllFields() of the record to retrieve all the fields for that record.
var fields = nlapiGetNewRecord().getAllFields()
// loop through the returned fields
fields.forEach(function(fieldName){
var field = record.getField(fieldName);
var fieldlabel = field.getLabel();
if(fieldlabel=='something'){
//do something here
return;
}
}
you can also get the list of available fields for a record here

Get TaskID for Case Activities

I was getting TaskID for Case Activities (Screen ID - SP203010) using Acumatica Web API. Now after upgrading it to version 6.0, I am not getting that. I have also tried different properties available but seems nothing is getting me that TaskID.
I am storing these activities into my database pulling from Acumatica Partner Portal and to avoid duplicate activities being imported, I was comparing it with TaskID.
Below is the code snippet I am using to get TaskID
SP203010WS.Screen context = new SP203010WS.Screen();
context.CookieContainer = new System.Net.CookieContainer();
context.AllowAutoRedirect = true;
context.EnableDecompression = true;
context.Timeout = 1000000;
context.Url = "https://sso.acumatica.com/Soap/SP203010.asmx";
PartnerPortalCreds loginCreds = GetCreds();
string username = loginCreds.PARTPRTUSE;
string password = loginCreds.PARTPRTPAS;
SP203010WS.LoginResult result = context.Login(username, password);
SP203010WS.Content content = context.GetSchema();
context.Clear();
string[][] export = context.Export
(
new SP203010WS.Command[]
{
new SP203010WS.Value
{
Value = currentAcumaticaCaseNo,
LinkedCommand = content.Case.CaseID
},
content.Activities.Type,
content.Activities.Summary,
new SP203010WS.Field { FieldName="Body", ObjectName="Activities"},
content.Activities.StartDate,
content.Activities.CreatedBy,
new SP203010WS.Field { FieldName="TaskID", ObjectName="Activities"},
},
null,
0, true, true
);
Let me know whether it has been moved or deprecated in newer version. What shall I be using instead of TaskID or where can I find that TaskID.
In Acumatica 6.0 table EPActivity was splitted on CRActivity, SMEmail and PMTimeActivity. Original table was renamed to Obsolete_EPActivity.
Now NoteID is the key field on all tables. SMEmail and PMTimeActivity contains RefNoteID field - foreign key from CRActivity.
You may find value pair TaskID and NoteID in table - Obsolete_EPActivity
#Krunal, as Ken mentioned, after upgrade to 6.0 value pair TaskID and NoteID is only available in the Obsolete_EPActivity table. One should use Obsolete_EPActivity table to replace obsolete TaskID integer values with actual NoteID GUIDs.
There is no way to access Obsolete_EPActivity table through Web Services. After upgrade to 6.0, Acumatica inserts new Activities only in the CRActivity table.
To avoid duplicate activities, you have to store actual NoteID GUIDs in your database instead of obsolete TaskID integer values and compare GUIDs while importing records.
For previously imported activities you will also have to replace TaskID values with actual NoteID GUIDs. Searching for CRActivity record based on CaseID, Subject and CreatedDateTime field values stored in your DB, you should find appropriate record and use its NoteID to replace legacy TaskID value.

Resources