I am making a web application and have a webform connected to an access database table. For one of my queries I have a table with supplier info and I need to filter the results by name, city, and type.
I used the query builder to have the parameters input by the user through 3 textboxes (one for each parameter). When I run the query in the query builder the results come up fine, but when I run it through a browser it fails (the form shows up fine, but it's not taking the input parameters in the textbox to populate the table). I made sure I linked the parameters to the texbox control through the wizard.
I've built forms with a single input parameter controlled with a single textbox and those have worked just fine, but when I used multiple parameters and textboxes it doesn't work in the browser.
I appreciate any help! Thanks!
Make sure you bind control with parameter.
<SelectParameters>
<asp:ControlParameter Name="Comments" PropertyName="Text" Type="String" />
<asp:ControlParameter ControlID="txtLastName" Name="Title" PropertyName="Text" Type="String" />
</SelectParameters>
You can pass parameters runtime as below.
<SelectParameters>
<asp:Parameter Name="Comments" Type="String" />
<asp:Parameter Name="Title" Type="String" />
</SelectParameters>
protected void AccessDataSource1_Selecting(object sender, System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs e)
{
if (txtFirstName.Text.Length > 0 && txtLastName.Text.Length > 0)
{
e.Command.Parameters["parameter1"].Value = txtFirstName.Text;
e.Command.Parameters["parameter2"].Value = txtLastName.Text;
}
}
Related
I am using report builder 3.0 to create reports in a vendor's environment where I only have access to their data sources. We have static data that we need to use in conjunction with the datasets we are creating from their models and I am trying to figure out how to add our data to a report to use for looking up values.
For Example:
The data set has AccountNo, OrderNo, ItemNo, Quantity, etc.
I need to be able to show some attributes about the ItemNo, like ItemName, ItemCost, ItemValue, etc.
I would like to have a dataset I can lookup against to get these values, but the only way I can get this to work is to create a report code function with hundreds of thousands of IF statements: IF ItemNo = "12345" Then ItemName = "XYZ Product"
This is slow and cumbersome to say the least. If the data sources were under my control, I could simply add a table in SQL, but I cannot in this environment. I have even tried linking to external datasource and that is not allowed by the environment. I am looking into creating some kind of XML data or trying to add data directly to the RDL, but I am running out of options.
Does anyone know of a any way to add a set of data or create an embedded dataset that contains static values. Any help would be greatly appreciated.
Thank you in advance,
Eric.
You could add a shared dataset that uses a table variable. So just create a new shared dataset and use a query like
DECLARE #t TABLE(ItemNo int, ItemName varchar(100))
INSERT INTO #t VALUES
(12345, 'XYZ Product'),
(23456, 'ABC Product')
SELECT * FROM #t
You could use this in each report and do a lookup to it to get the data you require.
Hopefully you have enough access to create a shared dataset, if not you would have to copy this to each report but it will be faster than thousands of IIFs
You could code this in VBA in the custom code section of the report. And/or make this a custom DLL which can source the data from wherever you want. The lookup code would be contained in the custom DLL in that case (pass in an input and the code returns the lookup).
Create a Data Source of Type XML
Create a Data Set and set the Data Source Created at step 1
Set Query Type to Text
Add some XML there is an example below
You should now see 3 columns in your output, I know its late but I was searching for this myself and hopefully will help someone else
<Query>
<XmlData>
<?xml version="1.0"?>
<Months>
<Month MonthValue="1">
<Name="January" />
<ShortName="Jan" />
</Month>
<Month MonthValue="2">
<Name="February" />
<ShortName="Feb" />
</Month>
<Month MonthValue="3">
<Name="March" />
<ShortName="Mar" />
</Month>
<Month MonthValue="4">
<Name="April" />
<ShortName="Apr" />
</Month>
<Month MonthValue="5">
<Name="May" />
<ShortName="May" />
</Month>
<Month MonthValue="6">
<Name="June" />
<ShortName="Jun" />
</Month>
<Month MonthValue="7">
<Name="July" />
<ShortName="Jul" />
</Month>
<Month MonthValue="8">
<Name="August" />
<ShortName="Aug" />
</Month>
<Month MonthValue="9">
<Name="September" />
<ShortName="Sep" />
</Month>
<Month MonthValue="10">
<Name="October" />
<ShortName="Oct" />
</Month>
<Month MonthValue="11">
<Name="November" />
<ShortName="Nov" />
</Month>
<Month MonthValue="12">
<Name="December" />
<ShortName="Dec" />
</Month>
</Months>
</XmlData>
</Query>
I have a custom SSRS report published to MS Dynamics 365 that I am trying to call on a form button-click. I want to run the report for a selected record of an Entity. I am able to retrieve the EntityGuid run-time and pass it to the report.
How do I get the ReportGuid in order to pass it as an argument in the url ?
What is an entityType in the Url and where do I find the value of a custom entity?
Url looks like this -
var url = serverUrl + "/" + organizationName + "/crmreports/viewer/viewer.aspx?action=run&context=records&helpID=" + rdlName + "&id={"+reportGuid+"}&records=" + entityGuid + "&recordstype=" + entityType;
window.open(url);
The XrmToolbox can help with both questions:
Using the FetchXML tester, this query will retrieve the names and GUID's of all the reports:
<fetch>
<entity name="report" >
<attribute name="name" />
<attribute name="reportid" />
</entity>
</fetch>
And the MetaData Browser shows each entity's ObjectTypeCode (a.k.a. EntityTypeCode or "etc").
And for the record, CRM provides a way to run a report from a form. After you configure the report to be available from the form, go to ellipsis and select Run Report:
Open Dynamics CRM -> Navigate to reports -> Find report you wand to get guid of -> select it and click "Edit" button in the Command Bar -> check url of window that popped up -> it should be something like https://yourorgname.crm.dynamics.com/CRMReports/reportproperty.aspx?id=%7b8484A9E3-3F8B-E611-80EE-C4346BAC897C%7d
Part after id= is your guid. In my case it is "8484A9E3-3F8B-E611-80EE-C4346BAC897C"
Good luck.
so, i was trying to implement a stored procedure with multiple results sets in entity framework.
it all seemed to be too easy.
but, i am not getting any rows for my results sets (even though, it seems i do get the result sets themselves back).
What i have done:
created the stored procedure which returns 3 result sets
Created the complex type that represents the return values
manually edited the edmx file as per Stored Procedures with Multiple Result Sets
Failed with 3 and tried the code version from the same page, still no rows back.
Reverted the code back to 3.
my edmx file (related content only):
<FunctionImport Name="getGlobalReport2">
<ReturnType Type="Collection(MTModel.GlobalReport2)"/>
<ReturnType Type="Collection(MTModel.GlobalReport2)"/>
<ReturnType Type="Collection(MTModel.GlobalReport2)"/>
<Parameter Name="regions" Mode="In" Type="String" />
<Parameter Name="countries" Mode="In" Type="String" />
<Parameter Name="companySizes" Mode="In" Type="String" />
<Parameter Name="products" Mode="In" Type="String" />
</FunctionImport>
<FunctionImportMapping FunctionImportName="getGlobalReport2" FunctionName="MTModel.Store.getGlobalReport2" >
<ResultMapping>
<ComplexTypeMapping TypeName="MTModel.GlobalReport2" />
</ResultMapping>
<ResultMapping>
<ComplexTypeMapping TypeName="MTModel.GlobalReport2" />
</ResultMapping>
<ResultMapping>
<ComplexTypeMapping TypeName="MTModel.GlobalReport2" />
</ResultMapping>
</FunctionImportMapping>
my code:
var x = mtEntities.getGlobalReport2(regions, countries, companySizes, products);
Response.Write(x.Count());
var y = x.GetNextResult<GlobalReport2>();
Response.Write(y.Count());
var z = x.GetNextResult<GlobalReport2>();
What i have allready checked:
Checked that the server receives the request as per How can I view live MySQL queries?
Run the query i grabbed from the server and made sure it returns result sets and rows
Debug the app to see there are no Exceptions i missed on the way
There seems to be no issue with the call, or the app, except that no rows are returned.
Any suggestions?
EDIT:
as per your comments about the edmx being overwritten, that would happen only if i regenerate the model from the database, not if i update it.
i wouldn't expect anything else, since its regenerating the model.
Dont you think you should have some property defined for your complex types you have created ? For example:
<FunctionImportMapping FunctionImportName="GetGrades"
FunctionName="SchoolModel.Store.GetGrades" >
<ResultMapping>
<ComplexTypeMapping TypeName="SchoolModel.GradeInfo">
<ScalarProperty Name="EnrollmentID" ColumnName="enroll_id"/>
<ScalarProperty Name="CourseID" ColumnName="course_id"/>
<ScalarProperty Name="StudentID" ColumnName="student_id"/>
<ScalarProperty Name="Grade" ColumnName="grade"/>
</ComplexTypeMapping>
</ResultMapping>
</FunctionImportMapping>
Check this too
Also as rightly stated by Mike in the comment to your question, if you in future update your edmx file, if it's regenerated you're going to lose to customizations.
I have a kind of login page where the user enters in data and based on that data it runs an sql query but I also need to have check boxes so the user can tailor these queries a little more and select only stuff they require.
Is there any way of having a check box then checking what the value of that is on a later form? Will I be able to pass it the same way I pass text?
<jsp:forward page="somepage.jsp">
<jsp:param name="empid" value="${(param.employeeid)}" />
<jsp:param name="recorddate" value="${(param.date)}" />
<jsp:param name="recorddate2" value="${(param.date2)}" />
</jsp:forward>
Also what data type does it pass am I after a boolean, string or integer?
When executing a report in MSCRM 2011, you have two options for the data sources : either SQL or Fetch.
In SSRS execution logs, the user who ran the report is always the service account.
When using fetch, in the report execution log, there is a parameter CRM_FullName containing the full name of the user who ran the report.
When using SQL source, there is no CRM_FullName parameter. How can I know who ran the report? There must be a way to know, since the Filtered views know who I am.
There is actually no way to find this information. When you create a report for MSCRM, you use a connector called "MSCRM Data Connector". This can be seen in the AdditionnalInfo column of the ExecutionLogs3 view on the SSRS instance. When using this connector and trying to show a report, you will get prompted for username and password. That's where things get interesting.
The report is not actually expecting a username/password! In fact, it expects to receive the systemuserid (guid) as username and the organizationid (guid) as password. It then search in the MSCRM_CONFIG database for the organization database settings. Then, it goes into the organization database and simply do a set context_info SYSTEMUSERID. Finally, the filteredviews are calling a function named '[dbo].[fn_FindUserGuid]' that retrieves the context_info. That is how the filtered views are properly working, while connected as the service account.
As you might have expected, we can't know the user who ran the report because the username and password prompts in SSRS are never logged anywhere (for security matters, perhaps).
The best option that I have found to log who ran a report is to actually create a stored procedure that will make a select statement on the filtered views (or any tables, as it is) and then log into a separate table the statement, the procedure parameters and the context_info(). Then, in SSRS I call that function instead of going to the filtered views directly.
Answer edited to include the getting the user fullname if sql source is used.
Register a parameter, UserID, with default value as
=User!UserID
Use the following query in your dataset
SELECT DomainName, FullName
FROM SystemUserBase
WHERE (DomainName = #UserID)
Then use
=Fields!FullName.Value
in your report.
In the CRM the user data is stored in the SystemUserBase table, and the DomainName column is the actual Domain\Username stored in User!UserID of the report.
If you prefer using views, use FilteredSystemUser view instead of SystemUserBase table.
For fetchxml try the following:
The operator operator='eq-userid' means equal to the current user.
<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>
<entity name='team'>
<attribute name='name' />
<attribute name='businessunitid' />
<attribute name='teamid' />
<order attribute='name' descending='false' />
<link-entity name='teammembership' from='teamid' to='teamid' visible='false' intersect='true'>
<link-entity name='systemuser' from='systemuserid' to='systemuserid' alias='user'>
<attribute name='fullname' />
<attribute name='systemuserid'/>
<filter type='and'>
<condition attribute='systemuserid' operator='eq-userid' />
</filter>
</link-entity>
</link-entity>
</entity>
</fetch>
Then in your report you can use the following code in an expression to get the users fullname
=First(Fields!user_fullname.Value, "GetUserData")
where the dataset is called GetUserData
Will the user login name suffice? i.e. can you just use something like
="Generated by " & User!UserID ?