Import/Use XrmServiceToolkit on Microsoft CRM 2013 - crm

how I use XrmServiceToolkit? Where I import this solution on Microsoft CRM 2013?

Hope this helps you. This is having all information related to xrmservicetoolkit.
https://xrmservicetoolkit.codeplex.com/
http://sumedha8.blogspot.in/2014/03/rest-functions-from-xrmservicetoolkit.html
Add the libraryto your CRM form:
Sample code to use the library:
function Retrieve() {
var re;
XrmServiceToolkit.Rest.Retrieve(
"{EE81D2A9-E28E-E311-96DF-D89D6765B238}",
"AccountSet",
null, null,
function (result) {
re = result;
alert("success");
},
function (error) {
alert("failed");
},
false
);
//debugger;
alert(re.Name);
alert(re.AccountId);
}
function Delete() {
XrmServiceToolkit.Rest.Delete(
"{32815A55-19AF-E311-BF0E-D89D6765B238}",
"AccountSet",
function () {
alert("successfully deleted");
},
function (error) {
alert("failed to delete");
},
false
);
}
function Update() {
var account = {};
account.Name = "SO and Company A1";
account.Address1_AddressTypeCode = { Value: 3 }; //Address 1: Address Type = Primary
account.Address1_City = "Wentworthville";
account.Address1_Line1 = "153 Dunmore Stret";
XrmServiceToolkit.Rest.Update(
"{EE81D2A9-E28E-E311-96DF-D89D6765B238}",
account,
"AccountSet",
function () {
alert("successfully Updated");
},
function (error) {
alert("failed to Update");
},
false
)
}
function Create() {
var account = {};
account.Name = "SO and Company B1";
account.Address1_AddressTypeCode = { Value: 3 }; //Address 1: Address Type = Primary
account.Address1_City = "Wentworthville B";
account.Address1_Line1 = "153 Dunmore Stret B";
XrmServiceToolkit.Rest.Create(
account,
"AccountSet",
function (result) {
accountId = result.AccountId;
alert("successfully Created. Acc ID : " + result.AccountId);
},
function (error) {
alert("failed to Create Account");
},
false
);
}

Related

Using Vue, but I can't query information from Firebase to display values in a chart/graph (google charts or GChart). "Error: Table has no columns."

This code is inside a .vue file. Receiving the "Error: Table has no columns." Inside the methods function, it won't receive the values from firebase to display a chart/graph to web app. What am I doing incorrectly? I think the values am I trying to receive inside "chartData:[ ]" or "mounted()" is incorrect and may be causing the issue. Any help is much appreciated.
export default {
name: "App",
components: {
GChart
},
methods: {
getHumidity(){
get(
query(ref(db, auth.currentUser.uid + "/Environment/humidity"),
orderByChild("humidity")
)
).then((snapshot) => {
if (snapshot.exists()) {
console.log(snapshot.val());
for (const item in snapshot.val()) {
this.pgoods.push({
humidity: snapshot.val()[item].humidity,
expir: snapshot.val()[item].humidity,
});
}
} else {
this.pgoods = [];
}
return float(snapshot.val());
});
}
getPressure(){
get(
query(ref(db, auth.currentUser.uid + "/Environment/pressure"),
orderByChild("pressure")
)
).then((snapshot) => {
if (snapshot.exists()) {
console.log(snapshot.val());
for (const item in snapshot.val()) {
this.pgoods.push({
pressure: snapshot.val()[item].pressure,
expir: snapshot.val()[item].pressure,
});
}
} else {
this.pgoods = [];
}
return float(snapshot.val());
});
}
getTime(){
get(
query(ref(db, auth.currentUser.uid + "/Environment/time"),
orderByChild("time")
)
).then((snapshot) => {
if (snapshot.exists()) {
console.log(snapshot.val());
for (const item in snapshot.val()) {
this.pgoods.push({
time: snapshot.val()[item].time,
expir: snapshot.val()[item].time,
});
}
} else {
this.pgoods = [];
}
return float(snapshot.val());
});
},
},
data(){
return{
chartData: [
["Time", "Pressure", "Humidity"],
[this.getTime(), this.getPressure(), this.getHumidity()],
[this.getTime(), this.getPressure(), this.getHumidity()],
],
},
mounted(){
this.getTemperature();
this.getHumidity();
},
}

Akryum: Vuex#1 for Meteor example app, addTrackers?

I don't really understand any of this from https://github.com/Akryum/meteor-vuex-example/tree/master/imports/vuex/modules: from init(data) all the way to if data in getters at the bottom references to vue instance data or state of vuex.
subModule.addTrackers({
selectedThread() {
let sub;
return {
init(data) {
data.selectedThread = null;
data.posts = [];
},
watch(state) {
// Dynamic subscription
if(sub) {
sub.stop();
}
if(state.selectedThreadId) {
sub = Meteor.subscribe('posts', state.selectedThreadId);
console.log('subscribed posts to thread ', state.selectedThreadId);
}
return {
id: state.selectedThreadId
}
},
update(data, {id}) {
data.selectedThread = Object.freeze(Threads.findOne({
_id: id
}));
data.posts = Object.freeze(Posts.find({
thread_id: id
}, {
sort: {created: -1}
}).fetch());
console.log('posts', data.posts);
},
getters: {
getSelectedThread: data => data.selectedThread,
getPosts: data => data.posts
}
}
}
})

Meteor.js : SearchSource + Publish composite

I'm currently creating a research engine for my app.
Until now, I used Publish composite + iron router : The user could had filters to search for some specific set of users.
Now, I want him to be able to look for some keywords too. For that I downloaded and tested the great SearchSource package.
The problem is that the SearchSource server side definition only seems to allow to return one cursor.
How could I combine the two logics ? Even if it's tricky, please, share.
Of course I could make an autorunned subscription where I look for every users loaded on the client and then subscribe to the additionnal documents, but it is not really the most performant and beautifull thing to do.
Some data :
Here is my current Publish Composite for filters :
Meteor.publishComposite("findTalkers", function(page, langs){
//console.log("Find Talkers");
//console.log("page : " + page);
//console.log("langs : " + langs);
if (langs.length)
{
return ({
find: function()
{
if (langs && langs.length)
{
var test = {$in: langs};
preSelectedUsers = [],
selector = {
_id: {$ne: this.userId},
"profile.completed": true,
"profile.firstName": {$exists: true},
"profile.languages.native": {$exists: false},
"profile.languages.lang": test
};
Counts.publish(this, "nbUsers", Meteor.users.find(selector, {
fields: {_id: 1}
}), {noReady: false, nonReactive: true});
if (page > 1)
{
preSelectedUsers = Meteor.users.find(selector, {
sort: {'profile.talkname': 1},
limit: 25,
skip: (25 * (page || 1)),
fields: {_id: 1}
}).fetch();
var i = -1;
while (preSelectedUsers[++i])
preSelectedUsers[i] = preSelectedUsers[i]._id;
}
if (page > 1)
selector._id = {$in: preSelectedUsers};
return Meteor.users.find(selector, {
fields: userFields,
sort: {'profile.talkname': 1},
limit: 25
});
}
},
children: [
{
// Finding user's profile picture if it is not url
find: function(user)
{
if (user && user.profile && user.profile.avatar.type != "url")
return Images.find({_id: user.profile.avatar.data}, {sort: {uploadedAt: -1}, limit: 1});
}
}
]
});
}
else
{
return ({
find: function()
{
return Meteor.users.find({_id: "flush"});
}
});
}
});
Here is my research with SearchSource :
Client :
var searchOptions = {
keepHistory: 1000 * 60 * 5,
localSearch: true
},
SearchSources = {
talkersSearch: new SearchSource('users', ['profile.talkname'], searchOptions)
};
Router.map(function(){
this.route('talkers/:page?',
{
template: "talkers",
onBeforeAction: function(pause){
(Meteor.user() && Meteor.user().profile.completed)
? this.next()
: this.render('/profile');
},
waitOn: function(){
var filters = MatesFilter.find().fetch(),
i = -1;
while (filters[++i])
filters[i] = filters[i].value;
if (filters.length)
{
return Meteor.subscribe("findTalkers", (this.params.page || 1), filters, function(){
Session.set('numberuser', Counts.get("nbUsers"));
});
}
return Meteor.subscribe('myself');
}
});
}
Template.talkers.helpers({
getPackages: function() {
return SearchSources.talkersSearch.getData({
transform: function(matchText, regExp) {
return matchText.replace(regExp, "<b>$&</b>")
},
sort: {isoScore: -1}
});
}
}
Template.talkers.events({
"keyup #header-search": _.throttle(function(e) {
Session.set("matesSearch", $(e.target).val().trim());
console.log("Searching for : " + text);
SearchSources.talkersSearch.search(Session.get("matesSearch"), {
page: (this.params.page || 1),
filters: filters
});
}, 200)
}
SERVER :
SearchSource.defineSource('users', function(searchText, options) {
var options = {sort: {"profile.talkname": -1}, limit: 25};
if(searchText)
{
var regExp = buildRegExp(searchText);
selector = { $or: [
{ "profile.talkname": regExp },
{ "profile.bio": regExp }
] };
return Meteor.users.find(selector, options).fetch();
}
return ;
});
All this Gives me two sources from which I can get users. I'd want to get a mean to merge the two ides (a composition of publication INSIDE the search, for example).
Thanks you.

How to join firebase data with the newest angularfire and fire util?

I have a list of categories and a list of products:
{
categories: {
'myCategoryId': {
name: 'my category name',
products: {
'first': true,
'second': true
}
}
},
products: {
'first': {
name: 'my product name',
categoryId: 'myCategoryId'
},
'second': {
name: 'my second product name',
categoryId: 'myCategoryId'
}
}
}
In my sidebar I want to show a joined list of categories with product names so I need some joined structure like:
{
categoriesWithNames: {
'myCategoryId': {
name: 'my category name',
products: {
'first': {
name: 'my product name'
},
'second': {
name: 'my second product name'
},
}
}
}
I know I can do this with Firebase util and AngularFire, but I've tried few different methods and I cannot grasp the concept of joining denormalized data in Firebase. Can anyone help me?
Code
var myApp = angular.module("myApp", ["firebase"]);
var FBURL = "MYFBURL";
var FBEVENTS = {
'deleted':'child_removed',
'added':'child_added'
};
myApp.controller('MyController', ['$scope', '$firebase',
function ($scope, $firebase){
var base = fb(FBURL);
function fb(url) {
return new Firebase(url);
}
function fbChild(attrs) {
return $firebase(typeof attrs === "string" ? base.child(attrs) : base.child(attrs.join("/")));
}
function $a(fbChild) {
return fbChild.$asArray();
}
function $o(fbChild) {
return fbChild.$asObject();
}
var products = fbChild('products');
var categories = fbChild('categories');
$scope.products = $a(products);
$scope.categories = $a(categories);
$scope.products.$loaded().then(function(){
$scope.categories.$watch(function (snapshot) {
console.log('snapshot is', snapshot);
if(snapshot.event!==FBEVENTS.deleted) {
var foundCat = $scope.categories.$getRecord(snapshot.key);
foundCat.products = _.map(foundCat.products, function (val, key){
if (val !== true)
return val;
return $scope.products.$getRecord(key);
});
}
});
});
}

Kendo UI Grid Fires CRUD Operations multiple times

I've seen this problem in many places but I can't seem to find a solution. So I have defined a Kendo grid with CRUD operations the thing is that the previous fired operations get fired again.
Say you delete entry X and then you add entry Y, the create operation fires and after that the delete operation (for X - which has been deleted) fires again. Same thing if you first create an element and then edit another, it edits the 2nd element and then it re-fires the 1st create statement and inserts a duplicate for the 1st inserted element. If you go on an on with several operations a nightmare happens with all the other previous operations being fired and sent to the controller.
My grid is:
function InitializeIPAddressesGrid(userID) {
selectedUserID = userID;
$(".ipAddresses").kendoGrid({
dataSource: IPAdressesDataSource,
sortable: {
mode: "single",
allowUnsort: false
},
remove: function (e) {
this.refresh();
var canDelete = confirm("Are you sure you want to delete this record?");
if (!canDelete) {
e.preventDefault();
}
},
height: 420,
resizable: true,
pageable: {
refresh: true,
pageSize: 10
},
selectable: "row",
toolbar: ["create"],
editable:{mode: "inline", confirmation:false} ,
columns: [{
field: "IpAddress",
title: "IP Address"
},
{
field: "Status",
title: "Status"
},
{
field: "LockedUntil",
title: "Locked until",
template: "#=kendo.toString(LockedUntil, 'yyyy/MM/dd' )#"
},
{ command: ["edit", "destroy"], title: " ", width: "180px" }
]
});
}
var IPAdressesDataSource = new kendo.data.DataSource({
type: "json",
serverPaging: true,
serverSorting: true,
serverFiltering: true,
pageSize: 10,
//scrollable:false,
transport: {
read: {
url: websiteRootUrl + '/PortalAuthorization/GetIPAddressesList',
},
update: {
url: websiteRootUrl + "/PortalAuthorization/UpdateIP",
dataType: "json",
type: 'POST',
complete: function (e) {
if (e.status != 200) {
alert(eval('(' + e.responseText + ')').Message);
}
}
},
create: {
url: websiteRootUrl + "/PortalAuthorization/CreateIP",
dataType: "json",
type: 'POST',
complete: function (e) {
if (e.status != 200) {
alert(eval('(' + e.responseText + ')').Message);
}
}
},
destroy: {
url: websiteRootUrl + "/PortalAuthorization/DeleteIP",
dataType: "json",
type: 'DELETE',
complete: function (e) {
if (e.status != 200) {
alert(eval('(' + e.responseText + ')').Message);
}
}
},
parameterMap: function (options, operation) {
if (operation == "update" && options) {
return {ipAddress: options.IpAddress ,
status: options.Status ,
lockedUntil: kendo.toString(options.LockedUntil, 'yyyy/MM/dd' ),
pkey: options.ID,
databaseID: selectedDatabaseID };
}
else
if (operation == "destroy" && options)
{
return {
databaseID: selectedDatabaseID,
pkey: options.ID,
userIDParam: selectedUserID
};
}
else
if (operation == "create" && options) {
return {ipAddress: options.IpAddress ,
status: options.Status ,
lockedUntil: kendo.toString(options.LockedUntil, 'yyyy/MM/dd' ),
pkey: options.ID,
userIDParam: selectedUserID,
databaseID: selectedDatabaseID };
}
else
{
options.databaseID = selectedDatabaseID;
options.userID = selectedUserID;
return options;
}
}
},
schema: {
model: {
id: "ID",
fields: {
IpAddress: { type: "string" },
Status: { type: "string" },
LockedUntil: { type: "date" }
}
},
data: function (data) {
return data.Items;
},
total: function (data) {
return data.TotalCount;
}
}
});
My controllers are:
public object UpdateIP(int databaseID, long pkey, string status, string lockedUntil, string ipAddress)
{
var database = [...];
DynamicDataRepository repository = [...];
string query = "...";
repository.ExecuteNonQuery(query);
return new HttpResponseMessage(HttpStatusCode.OK);
}
public object DeleteIP(int databaseID, long pkey, int? userIDParam)
{
var database = [...];
DynamicDataRepository repository = [...];
string query = "...";
repository.ExecuteNonQuery(query);
return new HttpResponseMessage(HttpStatusCode.OK);
}
public object CreateIP(int databaseID, long? pkey, string status, string lockedUntil, string ipAddress, int? userIDParam)
{
var database = [...];
DynamicDataRepository repository = [...];
string query = "...";
repository.ExecuteNonQuery(query);
return new HttpResponseMessage(HttpStatusCode.OK);
}
Do you have any ideea? where I've done something wrong? thanks in advance. P.S. the queries in the controllers work fine.
I fixed the problem, followed OnaBai's suggestion of returning the Updated/Created entity, and in the case of a Delete I returned the ID of the deleted entry.
public object UpdateIP(int databaseID, long pkey, string status, string lockedUntil, string ipAddress)
{
var database = [...];
DynamicDataRepository repository = [...];
string query = [...];
IPList updatedIP = new IPList { ID = pkey, IpAddress = ipAddress, Status = status, LockedUntil = DateTime.Today };
return Json(updatedIP, JsonRequestBehavior.AllowGet);
// return new HttpResponseMessage(HttpStatusCode.OK);
}
Only one mention: in the case of a CREATE, the method didn't seem to work so what I did is in the .complete event of the CREATE operation I did a ipGrid.dataSource.read();
ipGrid.refresh(); - so the operation doesn't repeat itself. ( I read that in this case there might be problem with the model definition - setting the ID field - but I did set that one). Many thanks to OnaBai

Resources