search master data service member by builtin attribute code - c#

I can search member by EntityMembersGetCriteria where SearchTerm containing expressions for custom attributes for exampel SAP Code = 'abc'.
var criteria = new EntityMembersGetCriteria
{
ModelId = new Identifier { Name = Model },
EntityId = new Identifier { Name = Entity },
VersionId = new Identifier { Name = Version },
SearchTerm = searchTerm,
MemberType = MemberType.Leaf,
MemberReturnOption = MemberReturnOption.DataAndCounts
};
However it does work with Code='xyz'.
Any idea pls?

SearchTerm sets WHERE clause search criteria to filter records. That means it is needed to put exactly the same names as it is stored in the MDS DB.
The point is that the user defined attributes (UDA) have special names in MDS DB.
Every UDA attributes is stored in the following format:
uda_{Entity.InternalId}_{Attribute.InternalId}, for example uda_2012_45231. In case of Entity.InternalId = 2021 and Attribute.InternalId = 45231.
So you have write into SearchTerm:
"uda_2012_45231 = 'abc'"
P.S.: You can find the values of the Entity and Attribute InternalIds within MetadataGet method.
UPDATE: It seems that UDA attributes do not work within SearchTerm at all. "Name", "Code", "EnterDTM" (CreatedDateTime) and "LastChgDTM" (UpdatedDateTime) are working, but the UDA are not.

Related

DynamoDB query returns zero results

I'm trying to query a DynamoDB table to find a product based on it's url.
The table has three fields: Title, Description & Url.
var credentials = new BasicAWSCredentials(awsDBLogins.AccessKey, awsDBLogins.SecretKey);
var client = new AmazonDynamoDBClient(credentials, RegionEndpoint.USEast2);
var context = new DynamoDBContext(client);
Table table = Table.LoadTable(client, "Products");
With the above code i'm able to connect to the table. I then execute the below query which does not return any error's however the list of results is empty. I am expecting one result to be returned where the Url matches "test".
var productUrl = "test"
QueryOperationConfig config = new QueryOperationConfig()
{
Filter = new QueryFilter(productUrl, QueryOperator.Equal, "Url"),
AttributesToGet = new List<string>
{ "Title", "Description", "Url" },
ConsistentRead = true,
};
var ProductItem = table.Query(config);
While this does not work in the code, I'm able to find the entry in the database when looking list of item's from the AWS web portal / console so I know that the entry exists.
Am I making a mistake in my filter?
I think the hash key name and value should be reversed. First parameter is the key name and third parameter is the value.
Filter = new QueryFilter("Url", QueryOperator.Equal, productUrl)

Filtering Google Calendar events with .C# API

I try to filter Google Calendar events by date in a .Net program.
I found resources only in other environnements.
The following code retrieves all events. The optional parameters are not used :-(
I think I do not send them to Google at all. I do not understand the "ParameterType" use and found no list of valid values. I simply copied the original parameter "ParameterType" value.
Any help will be apreciated!
var rq = service.Events.List( "primary" );
string startRFC3339 = "2017-04-19T00:00:00Z";
string endRFC3339 = "2017-04-22T00:00:00Z";
rq.RequestParameters["timeMin"] = new Google.Apis.Discovery.Parameter() {
Name = "timeMin",
ParameterType = "query",
DefaultValue = startRFC3339
};
rq.RequestParameters["timeMax"] = new Google.Apis.Discovery.Parameter() {
Name = "timeMax",
ParameterType = "query",
DefaultValue = endRFC3339
};
var events = requete.Execute();
I found the answer: do not focus on the RequestParameters collection.
It describes allowed parameters. It doesn't contain the parameters values.
Those values are in the request object itself:
var rq = service.Events.List( "primary" );
rq.TimeMin = aDateTime;
rq.TimeMax = aDateTime.AddDays(1);
var events = rq.Execute();
So simple...
.Net is strongly typed. I should have looked there first.

Creating product/Service in Quickbooks Online in an Invoice line item

I'm trying to create the service/product type in the invoice line item. It returns an error saying bad request, is my ItemRef phrased correctly. My service/product is created in qbo already, its called Subscription Fee, it's the 3rd in the dropdown list.
line.AnyIntuitObject = new Intuit.Ipp.Data.SalesItemLineDetail()
{
ItemRef = new Intuit.Ipp.Data.ReferenceType()
{
Value = "3",
type = "Item",
name = "Subscription Fee"
},
ItemElementName = Intuit.Ipp.Data.ItemChoiceType.UnitPrice,
AnyIntuitObject = (decimal)item.Rate, // Line item rate
Qty = (decimal)item.Quantity,
QtySpecified = true,
ServiceDate = DateTime.Now.Date,
ServiceDateSpecified = true,
TaxCodeRef = new Intuit.Ipp.Data.ReferenceType()
{
Value = taxCode0ZR.Id,
type = Enum.GetName(typeof(Intuit.Ipp.Data.objectNameEnumType), Intuit.Ipp.Data.objectNameEnumType.TaxRate),
name = taxCode0ZR.Name
},
};
What am i creating wrongly please help.
You cannot create an Item within an invoice or rather any entity within an entity.
QBO v3 does not supports creating entities on the fly.
You first need to do a create Item.
Get the Id of that Item and refer it in your Invoice.
Also, enable request/response log to get the details of the errors in log files-
https://developer.intuit.com/docs/0025_quickbooksapi/0055_devkits/0150_ipp_.net_devkit_3.0/0002_configuration/override_configuration

LightSwitch Entity: Updating the Value of Foreign Key Property

I am struggling with how I do the following in LightSwitch. I am 'intercepting' the entity during the partial void tblStaffExtendeds_Updating(tblStaffExtended entity) and then pulling some data from our local ldap and trying to set one of the properties of the entity to a specific value, like so:
partial void tblStaffExtendeds_Updating(tblStaffExtended entity)
{
string ldapPath = #"LDAP://DC=myLDAP,DC=myLDAP";
string user = entity.GPEmployeeID.ToString();
string[] props = {
ActiveDirectoryInfo.strings.DISPLAYNAME, ActiveDirectoryInfo.strings.EMAIL,
ActiveDirectoryInfo.strings.LOGONALIAS, ActiveDirectoryInfo.strings.PHONE,
ActiveDirectoryInfo.strings.OFFICE, ActiveDirectoryInfo.strings.TITLE,
ActiveDirectoryInfo.strings.GPEMPLOYEEID
};
var propResults = ActiveDirectoryInfo.UserPropertySearchByGPEmpID(user, ldapPath, props);
entity.tblAdminStaffType.StaffType = propResults[ActiveDirectoryInfo.strings.TITLE];
entity.WorkEmail = propResults[ActiveDirectoryInfo.strings.EMAIL];
entity.UserID = propResults[ActiveDirectoryInfo.strings.LOGONALIAS];
entity.WorkPhone = propResults[ActiveDirectoryInfo.strings.PHONE];
}
Now for fields like WorkEmail and WorkPhone this works fine as those properties are just strings and that is what I am getting from LDAP.
However I do I go about setting the StaffType which is a reference to an Admin Table entry? LDAP returns a string which matches the description on the Admin Table but on the Entity I would need to set it to the correct ID, I am assuming.
Is there someway to do this, short of creating "Look Up" methods to find the ID from the Admin Table by matching the Description to my String from LDAP?
The solution should look something like this:
string title = propResults[ActiveDirectoryInfo.strings.TITLE];
var qryAdminStaffType = from st in DataWorkspace.ApplicationData.StaffTypes
where st.Title == title
select st;
entity.tblAdminStaffType.StaffType = qryAdminStaffType.FirstOrDefault();
In this example, I'm assuming that your data source is called ApplicationData (the LS default name), that the StaffTypes table holds your staff types, and that you are matching the Title attribute. Note that if there is no match to the title, FirstOrDefalt() will return null.

Set operations in RavenDB

I read this article on ravendb set operations, but it didn't show me exactly how to update a set of documents via C#. I would like to update a field on all documents that match a certain criteria. Or to put it another way, I would like to take this C# and make it more efficient:
var session = db.GetSession();
foreach(var data in session.Query<Data>().Where(d => d.Color == "Red"))
{
data.Color = "Green";
session.Store(data);
}
session.SaveChanges();
See http://ravendb.net/docs/2.5/faq/denormalized-updates
First parameter is the name of the index you wish to update.
Second parameter is the index query which lets you specify your where clause. The syntax for the query is the lucene syntax (http://lucene.apache.org/java/2_4_0/queryparsersyntax.html). Third parameter is the update clause. Fourth parameter is if you want stale results.
documentStore.DatabaseCommands.UpdateByIndex("DataByColor",
new IndexQuery
{
Query = "Color:red"
}, new[]
{
new PatchRequest
{
Type = PatchCommandType.Set,
Name = "Color",
Value = "Green"
}
},
allowStale: false);

Categories

Resources