Out of stack space exception - dynamics-crm-2013

I am working in CRM 2013 where i need to set a date of my textbox and save it to CRM 2013 database.
look at my code :
var CRMForm = document.parentWindow.parent.Xrm.Page;
var currentDateTime = new Date();
CRMForm.getAttribute("date").setValue(currentDateTime);
But i am getting an exception here : Out of stack space

Are you working on a form or on a custom Web resource?
I'm getting confused because you are getting the parent form,
var currentDateTime = new Date();
Xrm.Page.getAttribute("requestdeliveryby").setValue(currentDateTime);
This should be more than enough. Remember that you need to register it properly when you edit the form:
Properties->Events->OnLoad ? Looking at your example looks like you are trying to get the Xrm namespace from the wrong form.

Got the solution myself and its as following :
var dt= CRMForm.getAttribute("date");
if(dt.getValue() != null)
{
dt.setValue(dt.getValue().setFullYear(currentDateTime.getFullYear()));
dt.setValue(dt.getValue().setDate(currentDateTime.getDate()));
dt.setValue(dt.getValue().setMonth(currentDateTime.getMonth()));
}

Related

Create an exact copy of Analysis Services database with AMO

I'm trying to automate the creation of an exact copy of an Analysis Services database using Microsoft.AnalysisServices namespace. My code is:
using (var server = new Server())
{
server.Connect(connString);
var newDb = server.Databases.GetByName(dbName).Clone();
newDb.Name = newDbName;
newDb.ID = server.Databases.GetNewID();
server.Databases.Add(newDb);
newDb.Update(UpdateOptions.ExpandFull);
server.Disconnect();
}
However it seems it creates an empty database instead because from SSMS i'm not able to see any tables, datasources and similar (check my screenshot here).
Is there a way to fix this? Thanks.
#gmarchi
You need to clone the child Model object using Model.clone() method as well to make to make it work. You can add Model using code like below -
var connString = "Provider=MSOLAP;Data Source=asazure://westus2.asazure.windows.net/xxxxxxxxxxxx:rw";
var dbName = "AW Internet Sales";
var newDbName = "CloneDb";
using (var server = new Server())
{
server.Connect(connString);
var newDb = server.Databases.GetByName(dbName).Clone();
var newModel = server.Databases.GetByName(dbName).Model.Clone();
newDb.Name = newDbName;
newDb.ID = server.Databases.GetNewID();
newDb.Model = newModel;
server.Databases.Add(newDb);
newDb.Update(UpdateOptions.ExpandFull);
server.Disconnect();
}
Please find below the screenshot after the code run.
Please let me know if you have any questions.
Thanks.

Sitecore Glass mapper GetItem<TypeName>(guid) always return null

I saw a related question:
Sitecore Glass Mapper always null
But unfortunately it does not give a solution for my case.
Here goes a code snippet:
var db = Factory.GetDatabase("master");
var context = new SitecoreContext();
// the ID of Needed item
var g = new Guid("{F21C04FE-8826-41AB-9F3C-F7BDF5B35C76}");
// just to test if it's possible to fetch item using db.GetItem
var i = db.GetItem(new ID(g), Language.Current, Sitecore.Data.Version.Latest);
// Grab item
var t = context.GetItem<Article>(g);
In the code above:
i is not null
t is null
Article is the simple class like:
[SitecoreType(TemplateId = "{4C4EC1DA-EB77-4001-A7F9-E4C2F61A9BE9}")]
public class Article
{
[SitecoreField(FieldName = "Title")]
public string Title { get; set; }
}
There are only one language installed in Sitecore - en, it has been specified in the web.config in the items as well.
Also I have added GlassMapperSc.Start(); to Application_Start in the Global.asax.cs and added my assembly to the list of included assemblies via var attributes = new AttributeConfigurationLoader(new[] { "Assembly.Name" }); and I succeeded to find my class in the SitecoreContext mappings.
It does not looks like a language issue, as stated in the link provided in the very beginning. And I'm struggling with it already for a pretty long time, but no luck...
Thank You!
I just noticed that you are using master db for the Sitecore DB and SitecoreContext for Glass.
The SitecoreContext class will use the database that is defined by the Sitecore.Context.Database property at runtime. This probably means that it is using the web database.
Can you check that you have published the item to the web database or instead using:
var context = new SitecoreService("master");

how to read Data context parameter from a crm to silverlight webresource

i have a silverlight webresource in my crm 2011.
now my task is to append a data parameter in url like
https://www.............../data=1234
now in silverlight application i need to read this data parameter.
i have tried to read the data
if (App.Current.Host.InitParams["data"] != string.Empty)
{
string CallerNumber = App.Current.Host.InitParams["data"];
...
and
i tried filtering the code to like
string url = System.Windows.Browser.HtmlPage.Document.DocumentUri.ToString();
var uri = new Uri(url);
var CallerNumber = uri.Query;
callernumber will have the ?data=1234
but still i am not able to get the data parameter. Do help
I believe that you will find those in the query string. You can access it like this
foreach (var item in HtmlPage.Document.QueryString)
{
//Do something like the data
}

Add parameter to Telerik report from codebehind using mvc 4

I am very new to Telerik Reporting as well as MVC. I am using Telerik Reporting Q1 2013 and MVC 4. I want to pass some info as parameter to report. I tried by sending parameter from code behind of report, but no use. It showing all record.
What I have done is
public partial class ImmunizationRpt : Telerik.Reporting.Report
{
public ImmunizationRpt()
{
InitializeComponent();
Telerik.Reporting.ReportParameter param = new ReportParameter();
param.Name = "PatientKey";
param.Type = ReportParameterType.Integer;
param.AllowBlank = false;
param.AllowNull = false;
param.Value = 1;
param.Visible = true;
this.Report.ReportParameters.Add(param);
//this.Report.ReportParameters.Add("PatientKey",ReportParameterType.Integer,1);
}
}
If the parameter is already defined in the report, you can access it through the collection.
this.Report.ReportParameters["PatientKey"].Value = 1;
thank you for reply! i have achived this as
my report was showing all records, because i hadn't set the report to filter the records based on the parameter value. To achieve that, first we need to add the new parameter from the code behind (as i did) and then we need to add a new filter as shown in the following code:
Telerik.Reporting.Filter filter1 = new Telerik.Reporting.Filter();
filter1.Expression = "=Fields.PatientKey";
filter1.Operator = Telerik.Reporting.FilterOperator.Equal;
filter1.Value = "=Parameters.PatientKey.Value";
report.Filters.Add(filter1);

Problem saving a new item to custom SharePoint 2007 list using Silverlight 4 UI control

I am hoping someone might be able to help me. I'm working on a Contact Manager built using a custom SharePoint 2007 list with a Silverlight 4 UI embedded in a content editor web part.
I am currently able to retrieve the data from the list and display it in a datagrid on the UI and everything works well.
Now I am trying to add the the ability to add new items to the list using the following code but the items do not save.
I've remotely debugged the following code using the Debug -> Attach to Process option and everything seems to execute successful without any errors but it does not save the item to SharePoint.
In order to simplify and get a working insert function I changed all the SharePoint fieds to single line text with the exception of the notes (multiline) and none of the fileds are required.
The sharepoint site does require Windows authentication but it seems to be working correctly as I am able to display it as well as add new items manually using the standard SharePoint forms.
Lastly, I have added the xml for the Batch element at the bottom which I copied as output while debuging.
Please let me know if there is any additional information I might be missing.
Thanks in advance for any assistance you might be willing to provide.
Charles
public string sharepoint_soap_namespace = "http://schemas.microsoft.com/sharepoint/soap/";
public string sharepoint_rowset_namespace = "#RowsetSchema";
public string service_lists_url = "http://myDomain/_vti_bin/lists.asmx";
public string listName = "MyContacts";
public void TestCreateContact()
{
Uri serviceUri = new Uri(service_lists_url);
BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None);
binding.MaxReceivedMessageSize = 2147483647; // This has to be the same as in the ServiceReferences.ClientConfig file.
EndpointAddress endpoint = new EndpointAddress(serviceUri);
ListsSoapClient testCreateClient = new ListsSoapClient(binding, endpoint);
XElement batch = new XElement("batch",
new XElement("Method",
new XAttribute("ID", "1"),
new XAttribute("Cmd", "New"),
CreateFieldElement("ows_ID", "New"),
CreateFieldElement("ows_Title", "John"),
CreateFieldElement("ows_SupportFor","USA"),
CreateFieldElement("ows_LastName","Doe")
));
testCreateClient.UpdateListItemsCompleted +=
new EventHandler<UpdateListItemsCompletedEventArgs>(createSoapClient_UpdateListItemsCompletedEventArgs);
testCreateClient.UpdateListItemsAsync(listName, batch);
testCreateClient.CloseAsync();
}
private XElement CreateFieldElement(string fieldName, string fieldValue)
{
XElement element = new XElement("Field",
new XAttribute("Name", fieldName),
fieldValue);
return element;
}
Just a quick update to let everyone know I was able to answer my own question.
It seems that in the batch XElement I was using the wrong field names.
CreateFieldElement("ows_SupportFor","USA"),
I was using "ows_SupportFor" instead of "SupportFor" without the "ows_" prefix.
Cheers,
Charles