How do I delete an item from a table having partition key and sort key, in AWS Amplify Flutter package. I need to know the flutter syntax for it - amazon-web-services

I want to delete item from table having partition key as userID and sort key as ID, but in a graphql delete request I see only the primary id as the field.
My delete function
Following is the syntax for the delete request:
final request = ModelMutations.deleteById(Todo.classType, 'some-todo-id-123');
I'm using amplify_api: ^0.4.5 package for graphQL requests.
I need help with the syntax for passing partition key and sort key both in the mutation request.

Related

NetSuite REST API with Postman: Record not found while using Suiteql

I'm trying to query some records like vendor and customer using suiteql with REST API using Postman.
The issue is that it return everytime the same error:
"Invalid search query. Detailed unprocessed description follows. Search error occurred: Record 'customer' was not found."
I tried:
differents syntax like Customer, CUSTOMER, customers, Customers, CUSTOMERS
but no change.
I added customer access to the role.
Is there something to activate while using suiteql with rest api?
Can you first try with select * from customer and see if any results are returned and then go on appending your conditions like date created greater than this year start
SELECT id, companyname, email, datecreated
FROM customer
WHERE datecreated >= BUILTIN.RELATIVE_RANGES('TFY', 'START')
AND datecreated <= BUILTIN.RELATIVE_RANGES('TFY', 'END');
NetSuite doesn't say it but for a record to be searchable, the user needs to have the following permissions:
Transactions:
Find Transaction
All the records needed
Lists:
Perform search
All the records needed
Setup:
REST WEB Services
Log in using Access Tokens or Oauth 2.0
Reports:
SuiteAnalytics WorkBook

Flutter AWS Auth: How to get custom user attribute?

How do I get in Flutter, the cognito custom user attribute for user?
await Amplify.Auth.fetchUserAttributes();
returns only user attributes but not the custom defined ones.
(I have added the attribute to the schema and I am sure it's there, in the AWS UI it's there.)
The fetchUserAttributes function returns a list of AuthUserAttributes including the custom ones you've defined. When you have that list you can iterate through it, and get the attributes you want.
const res = await Amplify.Auth.fetchUserAttributes();
for (var attr in res) {
if (attr.userAttributeKey == CognitoUserAttributeKey.custom('customAttr') {
customAttr = attr.value;
}
}
If the custom attribute isn't there, make sure the user have that attribute.
The issue was that these custom attributes, after they are created, they are not by default readable or writable.
For further explanations, check https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-attributes.html#user-pool-settings-attribute-permissions-and-scopes
Go to cognito - app clients - details - and very bottom to change permissions

Refresh model from JSON

I have a deeply nested model with one-to-one and one-to-many relationships. Initially I retrieved this model from server using standard ember-data API.
What I need to do now is to update model (and all its relationships) from a plain JSON retrieved by an AJAX call.
I cannot use reload() method, because that would make an additional HTTP request - I already have the JSON payload, so no need for an extra HTTP request.
Is there a way to reload a model from JSON?
You can use pushPayload/push for to add new records and update the existing records in store.
To revert all old changes, You can get all the records from store by peekAll, and iterate it for hasDirtyAttributes, if its true then unload it from store. after that you can use pushPayload to update the incomind records into store.
let allRecords = this.get('store').peekAll('modelname')
let dirtiedRecords = allRecords.filterBy('hasDirtyAttributes',true);
dirtiedRecords.forEach((item) =>{
item.unloadRecord();
});
//after that you can use pushPayload the result you got it from Ajax call.
Refer:
https://emberjs.com/api/data/classes/DS.Model.html#property_hasDirtyAttributes
https://emberjs.com/api/classes/Ember.Enumerable.html#method_filterBy
https://emberjs.com/api/data/classes/DS.Store.html#method_pushPayload

How to display only association value in prestashop web service response

How to print only association value in prestashop web service response.
this is my response url http://www.jpfabtex.com/api/products/?output_format=JSON&ws_key=&display=[id_default_combination,associations]
how to display associations value in json
You can't display only the associations node but you can display by the associations sub-nodes like this:
http://www.jpfabtex.com/api/products/?
output_format=JSON&ws_key=YOURWEBSERVICEKEY&display=[id_default_combination,categories[id],images[img]]
This will display de categories and images inside the associations node
you can not filter products using id_default_combination
you have to get all the combinations id first and then find each using this way
http://www.jpfabtex.com/api/combinations/?output_format=JSON&ws_key=&display=[full]&filter['id']=[implode('|',$combination_id_array)]

Sitecore ECM op-tin and opt-out roles dates

I want to know is there any way to get user subscrition / unsubscrition to email campaign ?
Is it saved in one of databases/tables in MSSQL ?
If you use the approach with opting in and out being determined on the fact if user is in role, then it is stored in the aspnet_UsersInRoles table in your core database. This table does not keep the information when role was assigned to the user. That's why you cannot get information when user subscribed or unsubscribed to email campaign.
The only thing you can check is if user is in the role:
user.IsInRole(roleName)
The user's subscription is driven by the users role, but It is possible to get the users subscriptions in ECM, You just have to use the api.
You can get the contact from the email address:
string fullName = commonDomain + "\\" + Util.AddressToUserName(username);
var contact = Contact.FromName(fullName);
var subscriptions = contact.GetSubscriptions();
Once you have a contact you can call the GetSubscriptions() method which will return the recipient lists the user is signed up to. There are a host of other methods you can call on a contact and if there is a a way to get the date unsubscribed/subscribed it will be here.
If not reflect Sitecore.EmailCampaign.dll and keep looking! There might be some extra information in the automation states table in the Analytics database. More info on automation state here:
https://www.sitecore.net/learn/blogs/technical-blogs/sitecore-magnified/posts/2013/09/ecm-automation-states-magic.aspx
Also noticed there is a method GetUnsubscribersStatistics on the Sitecore.Modules.EmailCampaign.Core.Analytics.AnalyticsHelper class. This will have the date of unsubscription.