parse server include pointer in relation query javascript sdk - javascript

Hello i am using a parse server as a backend for my ionic 2 app
now i have a table of users containing a freinds column with object ids from the same class and this cloumn type is a relation
i managed to get the user friends through the following code
var currentUser = Parse.User.current();
if (currentUser) {
var friendRelation = currentUser.relation('friends');
friendRelation.query().find({
success: function(friends) {
for (var i = 0; i< friends.length; i++) {
var object = friends[i];
this.friendsglobalvariable.push(object)
}
}
});
my problem is that each friend of these has a column of type pointer which points to photos class containg a profile picture
when i try to read this pointer it only gives me the object id of the photo
how i can get all the photo details from pointer included relation query

I managed to solve it my self
it already gives all the pointer details with the relation but the problem was that profile photo field for some friends was null
so i add some checks in the template and it works now

Related

Accessing Data in a relationship from another entity in a powerapp component

I have a one-to-many relationship between the accounts entity and a custom entity called clients where an account can have many clients. I am developing a powerapp component that I want to display details about the latest added client on the accounts main form.
What I’d like to know is how I would identify the account being viewed (as in get the relationship identifier) and retrieve the related data from the client entity.
Is this possible?
If I understand your relationship it is 1(Account)-->N (clients).
so based on this, on your every client record you will have a lookup filed (relationship) filed which will look up to Account Record.
below is an example for Javascript but this will give you understanding of data structure and relationship
Example: get all contacts for a Parent Account
// NOTE: retrieveMultipleRecords is available in offline mode, if you need this functionality change the call to Xrm.WebApi.offline.retrieveMultipleRecords
// https://learn.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/xrm-webapi/offline
Xrm.WebApi.online.retrieveMultipleRecords("contact", "?$select=contactid,_parentcustomerid_value,fullname&$filter=_parentcustomerid_value eq 7b649f5c-c986-e411-a2ea-00505693000c").then(
function success(results) {
console.log(results);
for (var i = 0; i < results.entities.length; i++) {
var result = results.entities[i];
// Columns
var contactid = result["contactid"]; // Guid
var parentcustomerid = result["_parentcustomerid_value"]; // Customer
var parentcustomerid_formatted = result["_parentcustomerid_value#OData.Community.Display.V1.FormattedValue"];
var parentcustomerid_lookuplogicalname = result["_parentcustomerid_value#Microsoft.Dynamics.CRM.lookuplogicalname"];
var fullname = result["fullname"]; // Text
}
},
function(error) {
console.log(error.message);
}
);

How to get list of contacts and meetings from Exchange Web Services using nodejs?

I searched google about this problem and I got some results:
How to get contact list from Exchange Server?
https://msdn.microsoft.com/en-us/library/office/jj220498(v=exchg.80).aspx
// Get the number of items in the Contacts folder.
ContactsFolder contactsfolder = ContactsFolder.Bind(service, WellKnownFolderName.Contacts);
// Set the number of items to the number of items in the Contacts folder or 50, whichever is smaller.
int numItems = contactsfolder.TotalCount < 50 ? contactsfolder.TotalCount : 50;
// Instantiate the item view with the number of items to retrieve from the Contacts folder.
ItemView view = new ItemView(numItems);
// To keep the request smaller, request only the display name property.
view.PropertySet = new PropertySet(BasePropertySet.IdOnly, ContactSchema.DisplayName);
// Retrieve the items in the Contacts folder that have the properties that you selected.
FindItemsResults<Item> contactItems = service.FindItems(WellKnownFolderName.Contacts, view);
// Display the list of contacts.
foreach (Item item in contactItems)
{
if (item is Contact)
{
Contact contact = item as Contact;
Console.WriteLine(contact.DisplayName);
}
}
But it seems to be a black box that only open for C# developers.
I can't see any URL or how to add WSDL file here (so I can do the same in Nodejs)
So how can I use Nodejs to get this information?
Thanks
There is no NodeJS specific API.
There is a javascript version of the EWS Managed API. You may be able to get this to work in NodeJS.

Get all information for login from form using javascript

Is it possible to get all the necessary information to log in using javascript?
I have a form object:
var form = getForm(); //some special function :-)
console.log(form.action); // "https://example.com/login"
console.log(form.method); // post
//next step get inputs for login name and psw, for example: name and ps
So, I can simulate post
https://example.com/login
post
name: admin
psw: harrypotter
BUT! Some web pages have another secret attribute stored in form html, like this:
action: login
I am looking for some automated method which can extract all informations need for login.
Do you have some idea how??
Thanks for any help.
You can use iteration to look at all of the properties of a element. You can then save these values to an array and then access the array to find values, such as action.
for (var i = 0; i < elem.attributes.length; i++) {
var attrib = elem.attributes[i];
if (attrib.specified) {
console.log(attrib.name + " = " + attrib.value);
}
}
Reference: https://stackoverflow.com/a/828330/5287820

How to access firebase db sub object elements?

My firebase db structure is given below,
users
fb-user-key1
user1-details1
Tags
Tag-key1
"name":"value"
Tag-key2
"name":"value"
fb-user-key2
user1-details2
Tags
Tag-key1
"name":"value"
Tag-Key1 & user-key's are generated by firebase with push(). firebase code to access the content is,
var fbref = firebase.database().ref("users");
fbref.child("Tags").on("child_added", function(e){
var Tagobj = e.val().name;
console.log(Tagobj);
});
This one is not returning anything. I am not able to access name:value pair in the above data structure.
`
adding modified code,
firebase.database().ref("users").on("child_added",function(e‌​) { var Tagobj = e.val().Tags; });
Output of the above code is output data structure
How to access that name value pairs?? firebase keys are issue?
Not getting, where I am wrong. Appreciate your inputs.
Since Tags is a child property of each user, then you have to read it off of each user object.
If you want all Tags for all users, assuming Tags for each user is not updated after a user is created, you can do this:
tagsPerUserId = {};
firebase.datatabs().ref('users').on('child_added', function(snap) {
tagsPerUserId[snap.key] = snap.value().Tags;
// TODO: Notify view that tagerPerUserId is updated and needs to be re-rendered
console.log(`Tags for userId ${snap.key}: ${snap.value().Tags}`);
});
This way you will also get Tags of new users when they are created, but you will not get updates to Tags of existing users.

Shopify Access a product with its id on thank you page without using '/admin' in url

I am trying to access a specific product using its id from the below url,
https://tempstore.myshopify.com/products/1234.json
Its giving me 404 error.
Although, I am able to access all products as below:
https://tempstore.myshopify.com/products.json
I have to access the product which was just processed in checkout process.
I have its id as below:
var products = Shopify.checkout.line_items;
products will contain an array of product id's only which are processed in checkout.Now I need to access all other properties of these products.
I can surely do this:
https://tempstore.myshopify.com/admin/products/1234.json
But it requires Authentication.
Any thoughts?
From the frontend, you need to have the product handle to get the JSON object:
https://tempstore.myshopify.com/products/[handle].js
or
https://tempstore.myshopify.com/products/[handle].json
(Note that the returned values from the .js and .json endpoints are quite different from each other!)
Like you point out, the Shopify.checkout.line_items array of objects only has the product IDs, not the product handles. We're not completely out-of-luck, though, because we can get the entire list of products in the store including the product handles by hitting the /products.json endpoint.
Of course, this means grabbing a potentially huge JSON object just to get information that we should've had included in the checkout line items... but unless there's some alternate source of the line item information available on the checkout page, looping through the entire list may be what you need to do.
So your end code would look something like this:
Checkout.jQuery.getJSON( // Or whatever your preferred way of getting info is
'https://tempstore.myshopify.com/products.json',
function(prodlist){
for(var p = 0; p < prodlist.length; p++){
var prod = prodlist[p];
// Find if Shopify.checkout.line_items contains prod.id, left as exercise for the reader
if(found){
Checkout.jQuery.getJSON(
'https://tempstore.myshopify.com/products/' + prod.handle + '.js',
function(product){
/* Whatever needs to be done */
})
}
}
}
)
Hope this helps!
var shop = Shopify.shop;
var lineItems = Shopify.checkout.line_items;
var url = 'https://' + shop + '/products.json?callback=?';
var requiredData = [];
$.getJSON(url).done(function(data){
lineItems.forEach(function(lineItemProduct){
data.products.find(function(product){
if(lineItemProduct.product_id == product.id){
requiredData.push(product);
}
});
});
});
console.log(requiredData);
This is how I solved it, If it helps anybody :)

Categories

Resources