Get all Guid in javascript crm 2011 - dynamics-crm-2011

I need to get all guids in an Entity by using Javascript crm 2011?for Ex:I have the Entity called Contact.In that contact Entity ther is an 5000 records.I need to get alll 5000 guid in a Javacript .
How to do this?

OData is limited to 50 records. To Retrive more than 50 records we have to use Paging
kindly check this RetrieveRecords

For a "bulk Get" you can try This solution
To get just one guid, you can use Web Resources(Simple HTML page).
<!DOCTYPE html>
<html>
<head>
<script>
function RetreiveGuid()
{
var guid = window.parent.Xrm.Page.data.entity.getId();
var cleanGuid =guid.replace(/{/g,"").replace(/}/g,"");
var entityName = window.parent.Xrm.Page.data.entity.getEntityName();
document.getElementById("demo").innerHTML = entityName + " : " + cleanGuid;
}
</script>
</head>
<body>
<h4>Using Web Resources to Get Guid</h4>
<p id="demo"></p>
<button type="button" onclick="RetreiveGuid()">Get Guid</button>
</body>
</html>

Related

Auto clear text after 10 minutes

My website auto clear text in tag input html after 10 minutes. also I set idle timeout session 1 hour
enter image description here
IMO: I think you should use blazor for this if you are using MVC with Razor Pages or some js framework.
The server does not have to manage the presentation layer.
If you just want to clear the text in the HTML input after a certain time then you could try to use setTimeout() function of JavaScript.
In the function, you could reset the input value.
Example:
<!DOCTYPE html>
<html>
<head>
<title>demo</title>
<script>
const myTimeout = setTimeout(clrval, 3000);
function clrval() {
document.getElementById("txt1").value = "";
}
</script>
</head>
<body>
<h1>This is test page....</h1>
<h2>Textbox value will be cleared after 3 seconds.</h2>
Test Field : <input type="text" id="txt1" value="This is my sample text..."></br>
</body>
</html>
Output:
Let me know if you have further questions.

Node.JS :How to forward to the login page with parameter?

I am building the login function with node.js, express,express-session, ejs.
This is the log-in page (i.e. index.ejs)
<html>
<head>
<meta charset="UTF-8">
<title>Video Chat Room</title>
<link rel="stylesheet" type="text/css" href="/css/style.css">
<style>
#message
{
color:red;
font-weight: bold;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$( document ).ready(function() {
var messageBox=document.getElementById("message");
<%
if (typeof errorField!="undefined") {
switch (errorField) {
case "email":%>
messageBox.innerHTML="Your email address has been used by another user, please use another one.";
document.getElementById("email").focus();
<% break;
case "logoutSuccess":%>
messageBox.innerHTML="<%=alias%> has successfully logged out.";
<% break;
}
}
%>
});
</script>
</head>
<body>
<form method="post" action="/login">
Nick name/Alias:<input type=text required name="alias" value="<%=((typeof user=='undefined')?'':user.alias)%>"><br>
Email Address:<input type=email id="email" required name="email" value="<%=((typeof user=='undefined')?'':user.email)%>"><br>
<input type="submit" value="Login">
</form>
<div id="message">
</div>
</body>
</html>
Here is the server-side code(i.e. server.js)
........
app.get('/',function (req,res) {
res.render('../ejs/index.ejs');
});
app.post('/login', function(req, res) {
var alias = req.body.alias;
var email = req.body.email;
var user=require("./classes/user.js");
user.alias=alias;
user.email=email;
if (user.login) {
req.session.user = user;
res.redirect('/home/');
} else {
res.locals.errorField="email";
res.locals.user=user;
res.render('../ejs/index.ejs');
}
It works fine, however, when the login process failed, although the web output the login page(i.e. index.ejs), the browser address bar still stay in "/login"; is it possible to change the browser address bar to "/" and the index.ejs can read the errorField and user value also?
If you want a user login error to go back to /, then you need to do res.redirect("/"). If you want to add some parameters to that page that can be used either in server-side rendering or client-side rendering, then the simplest way to do that is to add query parameters:
res.redirect("/?error=email")
Then, either your server-side rendering or some client-side Javascript can pick up that query parameter and display something like a message in the page that explains what happened.
There are lots of ways to do something like this. Here's a partial list:
Send data in a query parameter that server-side rendering picks up and adds some explanatory text to the page.
Send data in a query parameter that client-side Javascript picks up and adds some explanatory text to the page.
Set a cookie that contains an error message that your server-side rendering will pick upon the redirect and then clear the cookie.
Set some error data in the user session object on the server that your server-side rendering will pick up when rendering the redirected page and the clean that info from the session.
Use an Express middleware module built for these temporary messages called flash.
Render an error page from the server (without an immediate redirect) and then have a client-driven redirect back to "/" that occurs after a few seconds time. The client-driven redirect can either be from a <meta> tag or can be client-side Javascript on a timer.

hbs rendered site with handlebars.js in the script - nodejs

I use hbs to render my pages with partials for navigation and footers.
router.get('/test', function (req, res) {
return res.render('test');
});
On one page I have template that uses mustache.js. This template doesn't work as it should as the {{}} seems to be picked up on the hbs render. Below is a basic example that illustrates the error. If I load this as a static page with express I get "Joe is a Web Developer", if I render it with hbs I get "is a".
Are there any work arounds that wont involve me changing how all my pages are rendered?
<!doctype html>
<html lang="en">
<head>
<title>Mustache.js Inline Method</title>
<script type="text/javascript" src="js/libs/mustache.js" ></script>
<script>
var view = {
name : "Joe",
occupation : "Web Developer"
};
function loadtemp(){
var output = Mustache.render("{{name}} is a {{occupation}}", view);
document.getElementById('person').innerHTML = output;
}
</script>
</head>
<body onload="loadtemp()" >
<p id="person"></p>
</body>
</html>
It was simple enough. I just had to escape the brackets with a \
So all it took was
\{{name}}

How can i update one bound value when another value changes?

I have a smiple select control bound to model that contains 2 values: id -the value i want to bind to selected index, and cities= array i want ooptions populated from.
here is the JS:
var VM=function ViewModel() {
self=this;
this.id = ko.observable(102);
this.cities=ko.observableArray([]);
this.getCities=function(){
self.cities( [{"Key":"-1","Value":"choose city"},{"Key":"100","Value":"leningrad"}, {"Key":"102","Value":"moscow"}]);
} ;
}
var vm=new VM();
ko.applyBindings(vm);
I want cities to be populted after user clicked button, but the selected city must stay Moscow (because initialy the "id" was 102)
here is my HTML:
<!DOCTYPE html>
<html>
<head>
<script src="http://cloud.github.com/downloads/SteveSanderson/knockout/knockout-2.1.0.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<select data-bind="options:cities,optionsText:'Value',optionsValue:'Key',value:id"></select>
<button data-bind="click:getCities">get cities</button>
</body>
</html>
My problem is that selected index got lost after cities is loaded
Please help
Thanks
I figured out where my problem is:
the 'value' binding is two directional, so when firstly bound to select without options -the 'id' became -1.
When i cahnged to :
<select data-bind="options:cities,optionsText:'Value',optionsValue:'Key'"></select>
and added:
this.getCities=function(){
self.cities( [{"Key":"-1","Value":"choose city"},{"Key":"100","Value":"leningrad"}, {"Key":"102","Value":"moscow"}]
);
$('select').val(self.id());
} ;
The things started to work,
but problem now is how to collect value if user chooses some city after select populated:
my solution is to attach select change to unobtrusive jquery handler:
var VM=function ViewModel() {
self=this;
this.id = ko.observable(102);
this.cities=ko.observableArray([]);
this.getCities=function(){
self.cities( [{"Key":"-1","Value":"choose city"},{"Key":"100","Value":"leningrad"}, {"Key":"102","Value":"moscow"}]
);
$('select').val(self.id());
} ;
};
var f=function(){
vm.id($('select').val())
}
var vm=new VM();
ko.applyBindings(vm);
$('select').change(f)
I hope it will help somebody who experienced my problem...

passing objects parameter to facebook open graph custom actions in C#

I am posting custom action with facebook open graph api and I am successfully posted that on my timeline with facebook c# sdk.
Here is my action code
curl -F 'access_token=AccessToken' \
-F 'job=http://samples.ogp.me/476622222351784' \
'https://graph.facebook.com/me/sajidap:apply'
Here is my object code
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# sajidap: http://ogp.me/ns/fb/sajidap#">
<meta property="fb:app_id" content="APPID" />
<meta property="og:type" content="sajidap:job" />
<meta property="og:url" content="Put your own URL to the object here" />
<meta property="og:title" content="Sample Job" />
<meta property="og:image" content="https://s-static.ak.fbcdn.net/images/devsite/attachment_blank.png" />
I am posting in this way.
var fb = new FacebookClient(AccessToken);
var parameters = new Dictionary<string, object>
{
{ "og:type", "sajidap:job"},
{ "og:url" , "http://www.google.com"},
{ "og:image", "http://www.theappdynamics.com/images/babafooka.jpg" },
{ "og:title" , "Arslan Job"},
{ "job" , "http://samples.ogp.me/476622222351784"}
};
var Response = fb.post(me/NameSpace:ActionName,Parameters);
Its posting an activity on my timeline but its showing Sample activity of an object that is like this url http://samples.ogp.me/476622222351784
How I can give my own url, image and title of that object by passing with parameter dynamically from C#.
Please guide me on this thing
Its Simple i have done this. You have one page like that which have your Open graphs tags in it like this. Mean It should be some content page on your web.
Let me clear more.. Like I have one resturant and I am selling some chicken burgers and I want to make one action "Buy" Mean In facebook it should be like this Arslan buy chicken lawa on link.
In This Arslan is user who performed the action
And Action is buy
And Object was chicken lawa
And URL is my below page who have all open graph tags in it to show in feeds.
Here is ASPX Page
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server" prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# myapp: http://ogp.me/ns/fb/myapp#"> // Your app name will be replaced with this "myapp"
<title>Buy Falafeel</title>
<meta property="fb:app_id" content="4735" /> // Your APP ID
<meta property="og:type" content="myapp:falafeel" /> // YourAppName:Action Type
<meta property="og:url" content="http://demo.anything.net/buy.aspx" />
<meta property="og:title" content="Chicken Lawa Falafeel" />
<meta property="og:image" content="http://www.theappdynamics.com/images/babafooka.jpg" />
</head>
<body>
<form id="form1" runat="server">
<div>
This is Falafeel Page. Demo Demo......
</div>
</form>
</body>
</html>
Here I am Performing The action on button click from my code behind.
void PostAction(string URL, string Token, string Action, string objects)
{
var fb = new FacebookClient(Token);
var parameters = new Dictionary<string, object>
{
{ objects , URL}
};
try
{
dynamic result = fb.Post("me/myapp:" + Action, parameters); // again here should be your app name instead of "myapp"
}
catch { }
}
PostAction("URL", "AccessToken", "Action", "Object"); // Here is The Above Method Call
// Here is URL That URL Who Have Open Graph Tags Like we have created one page with tags named buy.aspx and it should be full link like "http://xyz.com/buy.aspx"
//Access Token Of User On Behalf we are going to create This Action
//Action The One Created On facebook App Setting Of OpenGraph Tag Like "Buy"
//Object That We Also Created On Facebook App Setting For OpenGraph Like "ChickeLawa"
Just publish an action with your object set to the OG URL of your object, as described here: https://developers.facebook.com/docs/opengraph/actions/#create
Anything else (picture, title etc.) will be fetched from the og:tags of the URL.

Resources