Am using HTML/javascript to connect to my mobile web service .
the select query is working fine without issues and the connection done ,now I want to update one row. The updating is not working in my html page, no error Alerting.the last alert line not reached . I need to update the status to "2"
This is my javascript
var TimeListTable = client.getTable('Match_Times');
//
TimeListTable.update({
id: "2",
status: "2"
}).read().done(function (result) {
alert("updating done")
}, function (err) {
alert("Error: " + err);
});
alert("reach here")
I fixed the problem ,, It was wrong to send string id , replacing id: "2" -> id: 2 will fix it and it works . Also I made it simple and it works
var TimeListTable = client.getTable('Match_Times');
TimeListTable.update({
id: 2,
status: "2"
});
alert("reach here")
There's an issue with your command (there's actually a bug just like this in one of the tutorials, which should be fixed soon, I'm guessing you got it from there): there should be no .read() call after the update call. Try changing your code to this, and it should work:
TimeListTable.update({
id: "2",
status: "2"
}).done(function (result) {
alert("updating done");
}, function (err) {
alert("Error: " + err);
});
Related
I am building a reactjs app that among others will include Braintree Dropin UI integration. So far, I have managed to make the UI show up and send a payload to the back end. However, I cannot get the gateway.transaction.sale() part to work. Here is my code's relevant parts:
When the user clicks the pay button, this is fired:
instance.requestPaymentMethod().then(function (payload) {
console.log(payload);
completePayment(amount, payload.nonce, userId, sessionId).then((result) => {
console.log( result );
});
}).catch(function (err) {
alert(err.message);
});
And this is the code that should handle the transaction:
return gateway.transaction.sale({
amount: amount,
paymentMethodNonce: nonce,
customFields: {
session_id: sessionId,
user_id: userId
},
options: {
submitForSettlement: true
}
}).then(function (result) {
if (result.success) {
console.log('Transaction ID: ' + result.transaction.id);
} else {
console.error(result.message);
}
}).catch(( error ) => {
alert(error);
});
Every time this function is fired, I get this error from catch:
TypeError: can't assign to property "success" on :not an object
Can anyone point me in the right direction?
Please note that I am not very familiar with react, node etc so my code may not be the best thing around...
Check these points:
make sure you assigned your environment to the sandbox (braintree.Environment.Sandbox);
double check (merchantId, publicKey, and privateKey).
There is a nice example how Rollup function could be called via MS CRM WebApi here.
But it covers general access to CRM WebApi. Although in most recent versions new JS namespace Xrm.WebApi was introduced. Which provides more straightforward way to access that endpoint.
Method Xrm.WebApi.execute should be able to execute Rollup request, as it is able to execute WhoAmI. But I'm struggling to figure out correct values of parameters to make this execution happen.
Here is my code:
var RollupRequest = function(entityType, id, query) {
this.Target = { entityType: entityType, id: id };
this.RollupType = "Related";
this.Query = {
Query: query
};
};
RollupRequest.prototype.getMetadata = function() {
return {
boundParameter: null,
parameterTypes: {
Target: {
typeName: "Microsoft.Xrm.Sdk.EntityReference",
structuralProperty: 5
},
RollupType: {
typeName: "Microsoft.Dynamics.CRM.RollupType",
structuralProperty: 3
},
Query: {
typeName: "Microsoft.Xrm.Sdk.Query.FetchExpression",
structuralProperty: 5
}
},
operationType: 1, // This is a function. Use '0' for actions and '2' for CRUD
operationName: "Rollup"
};
};
var request = new RollupRequest(
"contact",
"0473FD41-C744-E911-A822-000D3A2AA2C5",
"<fetch><entity name='activitypointer'></entity></fetch>"
);
Xrm.WebApi.execute(request).then(
function(data) {
console.log("Success: ", data);
},
function(error) {
console.log("Failure: ", error);
}
);
The code generates following URL:
/api/data/v9.0/Rollup(Target=#Target,RollupType=#RollupType,Query=#Query)?#Target={"#odata.id":"contacts(0473FD41-C744-E911-A822-000D3A2AA2C5)"}&#RollupType=&#Query={"Query":"<fetch><entity name='activitypointer'></entity></fetch>"}
and the error: "Expression expected at position 0 in ''."
Which, seems to be, indicates that RollupType was not set correctly, because indeed in URL RollupType is missing.
I assume there are more than one potential error, because I'm using FetchXML as query expression. But meanwhile is it possible indicate what should be changed to generate proper URL at least for RollupType property?
In our ember app, we are using following versions of ember-data and ember-data-factory-guy.
package.json
"ember-cli": "^1.13.8",
"ember-data": "1.13.9",
"ember-data-factory-guy": "1.13.10",
Note: we are using active-model adapter, not yet migrated to the json-api adapter.
import ActiveModelAdapter from 'active-model-adapter';
export default ActiveModelAdapter.extend({
Route: item.js
export default Ember.Route.extend(({
model(params) {
return this.store.findRecord('item', params.item_id);
}
});
Its working fine in development mode, but while running test cases, am facing following issue:
Test Case for "display single item" fails with following error:
{
"message": "Cannot read property '_internalModel' of undefined",
"name": "TypeError"
}
ember-data/lib/system/stpre/finder.js, fails at return statement
return promise.then(function (adapterPayload) {
Ember.assert("You made a request for a " + typeClass.typeClassKey + " with id " + id + ", but the adapter's response did not have any data", adapterPayload);
return store._adapterRun(function () {
var requestType = get(serializer, 'isNewSerializerAPI') ? 'findRecord' : 'find';
var payload = normalizeResponseHelper(serializer, store, typeClass, adapterPayload, id, requestType);
//TODO Optimize
var record = pushPayload(store, payload);
return record._internalModel;
});
(https://github.com/emberjs/data/blob/master/packages/ember-data/lib/system/store/finders.js#L32)
Are we missing anything here? Can anyone please help me to resolve this? I have tried by upgrading versions to latest, but still facing same issue.
posted in issues of ember-data-factory-guy
https://github.com/danielspaniel/ember-data-factory-guy/issues/136
In my case the problem was that the server's response didn't have the root element.
Server was returning for a user:
{
surname: 'surname',
name: 'name',
_id: 56ead1ace85b04be4a7e50e6
}
instead:
user: {
surname: 'surname',
name: 'name',
_id: 56ead1ace85b04be4a7e50e6
}
If you're querying the server using findRecord(), Ember expects the response to be in the form
{singularModelName: {...}}
If you're querying the server using query(), Ember expects the response to be in the form
{pluralModelName: [...]}
The type error will occur if you're not following that response pattern while using findRecord()
I mostly post this here as a reminder for myself. I run into this issue every couple weeks and come here to find an answer :)
This error was thrown while I was running acceptance tests because I forgot to tell ember-cli-mirage to generate fake models:
beforeEach(function() {
server.create('user', { id: window.sessionUser.id });
server.create('project', { userId: window.sessionUser.id });
});
Finally got the exact cause:
In my adapter/application.js
// Ember Data 2.0 Reload behavior
shouldReloadRecord: function() { return true; },
shouldReloadAll: function() { return true; },
shouldBackgroundReloadRecord: function() { return true; },
shouldBackgroundReloadAll: function() { return true; },
These lines I had added while fixing deprecation warnings, and because of this, it was causing records to be loaded always, although they were present in ember-data store. So now I just removed those.
http://emberjs.com/blog/2015/06/18/ember-data-1-13-released.html#toc_new-adapter-hooks-for-better-caching This reference helped me to get it understand much better :)
After spend 6 hours trying different approaches to my problem, I always get the same error and can't figure out why.
The problem is simple to understand: I have 10 users saved in Appcelerator Titanium ACS and I want to create 10 records, one for each user.
The stuff must be easy: all users have the same pass, so I only need to login with each one, create the object as the user and, thats all!! (In ACS, the objects are owned (and have user_id assigned automatically) by the user who creates them).
To manage async, I use functions with callback to wait till the end.
var Cloud = require('ti.cloud');
function createObject(value, onComplete) {
Cloud.Objects.create({
classname: 'MyObj',
session_id: Cloud.sessionId,
fields: {
value: value
}
}, function(data) {
if (data.success) {
Ti.API.info('New value: user [' + data.Scores[0].user_id + '] - value: ' + data.Scores[0].value);
onComplete(true);
} else {
Ti.API.info('Error: ' + data.message);
onComplete(false);
}
});
}
function login(user, onComplete) {
Cloud.Users.login({
login: user.username,
password: '1234'
}, function(e) {
if (e.success) {
createObject(20, function(cb) {
onComplete(true);
});
} else {
Ti.API.warn('Error login user: ' + e.message);
onComplete(false);
}
});
}
// Get target users
Cloud.Users.query({
response_json_depth: 1
}, function(data) {
if (data.success) {
_.each(data.users, function(user) {
login(user, function(cb) {
Ti.API.warn("user: " + user.username);
});
});
}
});
Well, my results are always the same:
Ti.API.warn('user: ' + user.username); shows the right users name (one by one), but Ti.API.info('New value: user [' + data.Scores[0].user_id + '] - value: ' + data.Scores[0].value); shows always the same user, meaning that all the values are saved for the same user (checked in DB, are all the same user), instead of 1 value per user.
I also tried to use async in the _.each command, but with the same results.
Where is the problem? I think I'm waiting in _.each user for the login, and the login must wait to finish the createObject, but seems I'm doing something wrong.
And here the exit. No sense for me...:
New value: user [54cb62cf18beba0935422a35] - value: 20
user: krusty
New value: user [54cb62cf18beba0935422a35] - value: 20
user: apu
New value: user [54cb62cf18beba0935422a35] - value: 20
user: ned
Note: the user_id saved for all calls correspond to user NED (the last)
It was a bug in ACS. Anyway, it doesn't matters currently, because was fixed 5 years ago.
I have a simple facebook app, when I click a button with javascript function, I show me Post was successful! Action ID: 685335521499641, but not appear on the timeline. Also, when I go to Open Graph -> Stories for check, my meta tags is not functioning right, only the image if I change it. I get the POST code from Get Code with some change on it.
I read many comments, but nothing for my issue. So how can I make it right ?
The function is:
FB.api('/me/the_name:action_type', 'post', {
photo: "http://samples.ogp.me/XXXXXXXXXXXXXXXX",
image: "http://path_to_my_image.jpg",
title: "The sample photo",
description: "Just for test !!!",
},
function(response) {
var msg = 'Error occured';
if (!response || response.error) {
if (response.error) {
console.log(response.error);
msg += "\n\nType: "+response.error.type+"\n\nMessage:"+response.error.message;
}
alert(msg);
}
else {
alert('Post was successful! Action ID: ' + response.id);
}
}
);
The case may be that, you have not submitted the actions for the approval yet.
But you can check the story in the Activity log in your timeline. Or, directly with this url: https://www.facebook.com/me/activity/RESPONSE_ID
Once approved, the stories will appear in the news feed.
If someone have the same issue like mine, think I success, it's work for me for now.
So first generate new own object with https://developers.facebook.com/tools/object-browser , with correct App: and Object Owner:, mine was http://samples.ogp.me/XXXXXXXXXXXXXXXX (from Get Code). In there put only the URL (may be and title), where the meta tags are, it will get the meta tags for this URL.
So it will be 1st version.
FB.api('/me/the_name:action_type',
'post',
{
photo: "http://The_URL_with meta_tags",
image: "http://path_to_my_image.jpg",
title: "The simple photo",
description: "Just for test !!!",
},
function(response) {
... see above ...
}
});
2nd version: Allow the User Messages and User Generated Photos if will want big image and comment.
FB.api('/me/the_name:action_type?image[0][url]=http://path_to_my_image.jpg&image[0][user_generated]=true',
'post',
{
photo: "http://The_URL_with meta_tags",
message: "a simple message will appear above the image" ,
},
function(response) {
... see above ...
}
});
I don't know this is the right way, but hope to help if someone have the same issue, it will be for a guide. (if is OK go for submit in Review Status)