DynamoDB query returns zero results - c#

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)

Related

NetSuite - Search customers by complex query

I am trying to search customers who contain these fields : email or firstName or lastName or id.
must be an OR condition between of them.
for example
var freeText = "shomeone#gmai";
var customers = SearchForCustomersWhoContainsThisData(freeText)
how can i build this query in c#?
public List<Customer> SearchForCustomersWhoContainsThisData(string search_text)
{
CustomerSearch custSearch = new CustomerSearch();
SearchStringField searchField = new SearchStringField();
searchField.#operator = SearchStringFieldOperator.contains;
searchField.operatorSpecified = true;
searchField.searchValue = search_text;
CustomerSearchBasic custBasic1 = new CustomerSearchBasic();
custBasic1.firstName = searchField;
CustomerSearchBasic custBasic2 = new CustomerSearchBasic();
custBasic2.lastName = searchField;
custSearch.basic = custBasic1;
//custSearch.basic = custBasic2; how to add this with or between
// Search for the customer entity who contains this text
SearchResult response = _crmNetSuitService.search(custSearch);
var searchResults = response.recordList.Select(t => (Customer)t).ToList();
return searchResults;
}
I expect to find customers who one of these fields contains this search-text:
email, fName, lName, Id.
As per NetSuite SuiteAnswers id 31408
Web Services > Search > How to set a field filter for one value OR another value
Currently, expressions are not supported via Web Services searches.
In order to Search where a field is one value or another. It is necessary to submit two search requests, then merge the results in the application code.

search master data service member by builtin attribute code

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.

ASP.NET Core Linq query for lists

I have this query that was recently changed to allow searches using lists. However, the logic doesn't seem correct. My initial search logic was as follows:
data = data.where(u=>u.location.contains(FilterInput.RepositoryName)).ToList();
This worked for individual inputs and the logic made sense. In the data result, check if location field contains the Input variable
However in order to handle inputs that are lists, I had to change it to the bottom code which is in this Input list, check if the it contains the location field.
The database outputs data as follows:
Output = {arhde, brhje, ckio}
That means my list input is a small section of what the database contains.
FilterInput.RepositoryName = {a,b,c}
data = (from item in dbContext.Documents
join id in initialData
on item.Id equals id.DocumentId
select new DocumentsListViewModel
{
Id = item.Id,
Name = item.Name,
ApplicationName = item.ApplicationName,
ApplicationSecretKey = item.ApplicationSecretKey,
Link = item.Link,
Location = item.Location,
FileType = item.FileType,
CreatedOn = item.CreatedOn
}).ToList();
if (FilterInput.RepositoryName.Count>0)
{
data = data.Where(u => FilterInput.RepositoryName.Contains(u.Location)).ToList();
}
I don't know if its possible to change this logic to use the first one but accomodate lists as well?

how to get the index/ order of a defect in the Backlog, Rally Rest API C#

Task:
List all defects in the backlog of a project by their rank/index.
Here is my code:
var myRequest = new Request()
{
ArtifactName = "defect",
Limit = 2000,
Query = new Query("Project.OID", Query.Operator.Equals, MyDefectProjectOID),
Fetch = new List<string>() { "true" }
};
QueryResult queryMyResult = api.Query(myRequest);
Question:
1) How do I get the result set back in the order my users have organised them in Rally.
2) Is there a value on the defect item that tells me the rank/index (for example the Task item has a TaskIndex property)
1) Order by the DragAndDropRank field, ASC.
2) As long as you fetch DragAndDropRank as well that's your rank value. It's encoded as a string which is sortable in client code. The overall numeric index will be its index in your result set.
Another quick note- rather than specifying a query on Project.ObjectID to control scoping, you can just set the Project, ProjectScopeUp and ProjectScopeDown values:
Project = "/project/" + MyDefectProjectOID,
ProjectScopeUp = false,
ProjectScopeDown = false

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

Categories

Resources