Cannot retrieve money attribute using REST javascript - dynamics-crm

I'm tweaking the REST sample located here for my custom entity http://msdn.microsoft.com/en-us/library/hh223541.aspx
It retrieves and displays the table for all attributes except money. That is, if my requested attributes don't include an attribute of type money the table displays. Once I add a money attribute nothing is displayed. Below is my custom html. I'm using the same SDK.OptionSetSample.js included in the sample vs solution.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=9" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Contacts Page</title>
<script src="../../ClientGlobalContext.js.aspx" type="text/javascript"></script>
<script src="Scripts/json2.js" type="text/javascript"></script>
<script src="Scripts/SDK.OptionSetSample.js" type="text/javascript"></script>
<script src="Scripts/SDK.MetaData.js" type="text/javascript"></script>
<script src="Scripts/SDK.REST.js" type="text/javascript"></script>
<link href="Styles/OptionSetSample.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
var attributes = [
"new_revenuesportspartnershipsId",
"new_name",
"new_PledgeorCash",
"new_Designation",
"new_DonorStatus"
, "new_FY2011"
];
var ContactListTableData = {
Id: "ContactList",
BodyId: "ContactListBody",
CheckboxColumn: true,
SearchFieldId: "SearchString",
CreateButtonId: "createContact",
DeleteButtonId: "deleteSelectedRecords",
Columns: [
{ Name: "new_name" },
{ Name: "new_PledgeorCash" },
{ Name: "new_Designation" },
{ Name: "new_DonorStatus" }
,{ Name: "new_FY2011" }
]
};
var CurrentContactForm = {
Id: "CurrentContact",
SaveButtonId: "SaveCurrentContact",
CloseFormControlId: "closeFormSpan"
};
window.onload = function () {
SDK.OptionSetSample.Entity = "new_revenuesportspartnerships";
SDK.OptionSetSample.Columnset = attributes;
SDK.OptionSetSample.PrimaryIdAttribute = "new_revenuesportspartnershipsId";
SDK.OptionSetSample.TextSearchAttribute = "new_name";
SDK.OptionSetSample.PrimaryAttribute = "new_name";
SDK.OptionSetSample.TableData = ContactListTableData,
SDK.OptionSetSample.FormData = CurrentContactForm;
//Get the Attribute metadata
SDK.OptionSetSample.getAttributeMetadataCollection.Execute();
}
</script>
</head>
<body>
<ul id="message">
</ul>
<div>
<button id="createContact">
Create</button>
<button id="deleteSelectedRecords" disabled="disabled">
Delete Selected Contacts</button>
<span id="searchBy">Search by Full Name :</span><input id="SearchString" type="text" />
<table id="ContactList" class="RecordList" />
</div>
<div id="CurrentContact" class="editForm">
<span id="closeFormSpan" class="closeFormSpan">X</span>
<!-- Only Boolean, Picklist, Status, and String attribute types are supported in this sample.-->
<div id="new_nameField">
</div>
<div id="new_PledgeorCashField">
</div>
<button id="SaveCurrentContact" disabled="disabled">
Save</button>
</div>
</body>
</html>

The sample script looks like this for Money as it has a case already:
case "Money":
case "Integer":
var Value = record[AttributeMetadata.SchemaName];
record[AttributeMetadata.SchemaName] = {};
record[AttributeMetadata.SchemaName].Value = Value;
record[AttributeMetadata.SchemaName].isDirty = false;
In the two cases outlined, Integer will work fine as it is a primitive type and so will return the actual numerical value into record[AttributeMetadata.SchemaName].Value
However the money type is a complex object so that is assigned to the same variable but wont actually give you the value it represents just the object which is why it isn't displaying. You actually need a further .value on the end to retrieve the numerical value it represents.
Either change the switch to this:
case "Integer":
var Value = record[AttributeMetadata.SchemaName];
record[AttributeMetadata.SchemaName] = {};
record[AttributeMetadata.SchemaName].Value = Value;
record[AttributeMetadata.SchemaName].isDirty = false;
case "Money":
var Value = record[AttributeMetadata.SchemaName];
record[AttributeMetadata.SchemaName] = {};
record[AttributeMetadata.SchemaName].Value = Value.value;
record[AttributeMetadata.SchemaName].isDirty = false;
or when you put the money attribute in your table make sure that the value that gets shown is record[AttributeMetadata.SchemaName].Value.value
I think its a lower case for value it might be upper Value
Hope that makes sense.

Related

json print required data with ng-repat

i am new to coding and i am starting with angular js....
i have a json like below
$scope.data={
"items":
{
"yamaha":
{
"title":"R15",
"description":"sports mode",
"speed":"180kmph"
},
"Tvs":
{
"title":"apache",
"description":"sports mode",
"speed":"150kmph"
}
}
};
now my requirement is to show each value one after other in html.....
Note
As i said i am new,i have googled this and found some info like ng-repeat but i didnt understand how to use this in while implementing.
thanks for your response
ng-repeat will iterate over the data in the given array....here i used key,vakue concept to print object keys and values
<!doctype html>
<html ng-app="plunker" >
<head>
<meta charset="utf-8">
<title>AngularJS Plunker</title>
<script>document.write('<base href="' + document.location + '" />');</script>
<link rel="stylesheet" href="style.css">
<script src="http://code.angularjs.org/1.1.4/angular.js"></script>
<script src="app.js"></script>
</head>
<body ng-controller="MainCtrl">
<div ng-repeat="(k,v) in data.items">
<div><h2>{{k}}</h2>
<p>{{ v.title }}</p>
<p>{{v.description }}</p>
<p>{{v.speed }}</p>
</div>
</div>
</body>
<script>
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
$scope.data={
"items":
{
"yamaha":
{
"title":"R15",
"description":"sports mode",
"speed":"180kmph"
},
"Tvs":
{
"title":"apache",
"description":"sports mode",
"speed":"150kmph"
}
}
};
});
</script>
</html>

Kendo numberFormat change in culture

I want to format numeric column value as 55,25,236.30 in grid. I created a JS function and called from column template in grid. My JS function:
function NumberFormater(Price) {
kendo.culture("en-US");
kendo.cultures.current.numberFormat.groupSize = [3,2];
return kendo.toString(Price, "##,#.00");
}
but the value is showing like 5,525,236.30. According to this link the default value for groupSize is [3]. Is it not possible to set multiple values like [3,2] like numberformat in C#?
Make sure that the NumberFormater function receives a numeric argument. Below is a test page that works.
On a side note, I am not sure there is a need to set the culture and groupSize every time you execute the function.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled</title>
<link rel="stylesheet" href="http://kendo.cdn.telerik.com/2016.3.914/styles/kendo.common.min.css">
<link rel="stylesheet" href="http://kendo.cdn.telerik.com/2016.3.914/styles/kendo.default.min.css">
<script src="http://code.jquery.com/jquery-1.12.3.min.js"></script>
<script src="http://kendo.cdn.telerik.com/2016.3.914/js/kendo.all.min.js"></script>
</head>
<body>
<input class="k-textbox" type="number" value="5525236.3" />
<button id="format" class="k-button">Format numeric value</button>
<script>
$("#format").click(function(){
var formattedValue = NumberFormater(parseFloat($(".k-textbox").val()));
alert(formattedValue);
});
function NumberFormater(Price) {
kendo.culture("en-US");
kendo.cultures.current.numberFormat.groupSize = [3,2];
return kendo.toString(Price, "##,#.00");
}
</script>
</body>
</html>

jQuery multiple tabs + validation select does not fire (MVC3/Razor/VB)

I've used a solution here (which I've fiddled here) for restricting submission of a form until all required fields are filled.
The problem is when I run on my MVC3 project, as I've observed on Firebug, it stops starting at the third line of the following block. Because of it, the solution doesn't work.
var validator = $("#myForm").validate();
var tabs = $("#tabs").tabs({
select: function(event, ui) { // Here.
// The following lines are not executed.
var valid = true;
var current = $(this).tabs("option", "selected");
var panelId = $("#tabs ul a").eq(current).attr("href");
Can somebody tell me why my project won't run the rest of the script and what I should do to fix it? Thanks!
In my View file
#ModelType SLC.Models.RegisterModel
// downloaded with NuGet
<script src="#Url.Content("~/Scripts/jquery.validate.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/jquery.validate.unobtrusive.js")" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
var validator = $("#myForm").validate();
console.log(validator);
var tabs = $("#tabs").tabs({
select: function (event, ui) {
var valid = false;
var current = $(this).tabs("option", "selected");
var panelId = $("#tabs ul a").eq(current).attr("href");
$(panelId).find("input").each(function () {
console.log(valid);
if (!validator.element(this) && valid) {
valid = false;
}
});
return valid;
}
});
});
</script>
<link rel="stylesheet" href="#Url.Content("~/Content/themes/base/jquery-ui.css")" />
#Using Html.BeginForm("", "", Nothing, New With {.id = "myForm"})
#Html.ValidationSummary(True, "Account creation was unsuccessful. Please correct the errors and try again.")
#<div>
<div id="tabs">
<ul>
<li>1. Information</li>
<li>2. Information</li>
<li>3. Confirm</li>
</ul>
<div id="tab-1">
// Some fields...
</div>
<div id="tab-2">
// Some fields...
</div>
<div id="tab-3">
// Some fields...
<input type="submit" value="Register" />
</div>
</div>
</div>
End Using
In my Layout template file
<head>
<link href="#Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
// downloaded with NuGet
<script src="#Url.Content("~/Scripts/jquery-1.9.1.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/jquery-ui-1.10.0.js")" type="text/javascript"></script>
</head>
I found this:
The jQuery UI select method, in particular, is deprecated as of 1.10.0, so it's either back to UI 1.9.2 or a code rewrite.

rally: How to get a dropdown updated automatically after I change another dropdown menu?

I am trying to setup two dropdown menus. The values in one depend on the current value of the other. How do I link them in a way that when i changed the selected value in one drop down menu, it automatically updates the other dropdown menu?
Thanks.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>User Stories By Iteration</title>
<meta name="Name" content="App Example: User Stories Table" />
<script type="text/javascript" src="/apps/1.32/sdk.js"></script>
<script type="text/javascript">
var rallyDataSource;
var relDropdown;
var table;
var relDropdown2;
function onReleaseSelected(releases, eventArgs) {
var queryConfig = {
type : 'testset',
attribute : 'Name',
query: '(Release.Name = "' + releases.getDisplayedValue() + '")'
};
relDropdown2 = new rally.sdk.ui.ObjectDropdown(queryConfig, rallyDataSource);
relDropdown2.display(document.getElementById("releaseDiv2"));
}
function onLoad() {
rallyDataSource = new rally.sdk.data.RallyDataSource('__WORKSPACE_OID__',
'__PROJECT_OID__',
'__PROJECT_SCOPING_UP__',
'__PROJECT_SCOPING_DOWN__');
var relConfig = {};
relDropdown = new rally.sdk.ui.ReleaseDropdown(relConfig, rallyDataSource);
relDropdown.display(document.getElementById("releaseDiv"), onReleaseSelected);
}
rally.addOnLoad(onLoad);
</script>
</head>
<body>
<div>
<div id="releaseDiv"></div>
<div id="releaseDiv2"></div>
</div>
<br/><br/>
</body>
</html>
SDK 1.x dropdowns cannot have their values refreshed once they are rendered. What you can do however is destroy the second dropdown and recreate it in response to the first dropdown's change event.
So in your onReleaseSelected just add the following code before creating and displaying a new one:
if(relDropdown2) {
relDropdown2.destroy();
}

Add / Remove Elements Dynamically

Now i done the ADD /Remove Elements
How to add/remove elements dynamically, pease find the image attachment, which shows the better understand,
category which populate records from database category table, and when user select the particular category than sub category will populate from datbase sub category table,
am looking one jquery or some open which do this same work,
refer some good plugins,
How to add the element when i click the ADD Elment, please chekc my code below
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript" >
$(document).ready(function(){
var hdn_add_element_cnt = $("#hdn_add_element_cnt").val();
hdn_add_element_cnt = parseInt(hdn_add_element_cnt);
var app_str = "<div id=element_"+hdn_add_element_cnt+">New Element "+hdn_add_element_cnt+" Delete</div>";
$('#element_area').append(app_str);
$("#add_element").click(function(){
var hdn_add_element_cnt = $("#hdn_add_element_cnt").val();
hdn_add_element_cnt = parseInt(hdn_add_element_cnt);
hdn_add_element_cnt = hdn_add_element_cnt+1;
var app_str = "<div id=element_"+hdn_add_element_cnt+">New Element "+hdn_add_element_cnt+" Delete</div>";
$('#element_area').fadeIn(10000).append(app_str);
//Increment Elemenet ID Count +1
document.getElementById("hdn_add_element_cnt").value = hdn_add_element_cnt;
})
})
function delete_element(element_id_no){
var get_element_hidden_cnt = $("#hdn_add_element_cnt").val();
$("#element_"+element_id_no).fadeOut(100).remove();
}
</script>
</head>
<body>
<div style="width:500px; height:200px; background-color:#FF0000;">
<div id="add_element" style="width:400px; height:75px;">
ADD Element
</div>
<div id="element_area">
</div>
</div>
<input type="hidden" id="hdn_add_element_cnt" value="1" />
</body>
</html>
jQuery doesn't need plugins to do this. Standard functions work well:
.append() adds elements, so to add a <div> to the <body>, just do this:
$('body').append('<div id="foobar">This is my text</div>');
.remove() similarly removes elements, so to remove that <div> that you added, just do this:
$('#foobar').remove();
.html() and .text() can be used to set the contents of an element. .text() is usually for setting the displayed text, and .html() is for adding content elements:
$('#foobar').text('Hello');
$('#foobar').html('<h1 class="foo">Hello</h1>');
Your question is really vague, so I'm not sure what else to say.

Resources