Add numbers in Plugin Dynamics CRM 2015 - plugins

How can I code for adding two numbers from two fields on LEAD form and putting result in third field on that same form in Dynamics CRM 2015 online? I am creating a plug-in and there is no function like (entity.setAttribute) but have a function (entity.getAttribute). So I am failing to put the result in third field.

The Entity's method SetAttributeValue is protected and therefore not accessible.
Just use this syntax:
myEntity["calculatedFieldName"] = 1 + 2;

Related

ms-access linking each checkbox(true/false column) to run a individual code in forms

New Edition June 2, 2017
I'm creating a database for a preventative maintenance program for the equipment in my facility. We have about 70 different machines with individuals preventative maintenance instructions, and I've been able to create tables for machines with the instructions attached to them by using forms that will update the database. I created a main form that will filter which PM needs to be done based on the date that is searched that will filter through the machines in the database, access does this fine. The problem I'm currently having trouble with is finding a way to add checkboxes to this main form, and print off only the ones that are selected with a button. The plan we have is to have the mechanics to be able to print off the PM instructions, and use the print off to update the database. Is there a way this can be done with checkboxes or optionboxes?Here's a picture of the main form that doesn't have the checkbox field attached to it yetHere's a picture of the forms that will show the preventative maintenance instructions that we will be printed.
Your question is a little vague and doesn't provide any insight on what you might have tried (this would actually help us determine what you want to do). That said, based on what's given:
If you have a single checkbox and want some action to be performed when it is checked/unchecked.
Private Sub CheckboxName_Click()
If CheckboxName.Value = -1 Then
'Do something
Else
'Do something else (Else is optional)
End If
End Sub
If you have multiple checkboxes you want to confirm which are checked and which aren't when a button or something is pushed you use the Controls object to cycle through all the checkboxes.
Private Sub ButtonName_Click()
Dim ctrl as Control
Dim i as Integer
For Each ctrl In Me.Controls
If ctrl.ControlType = acCheckBox and ctrl.Value = -1
'Do something (e.g., Select Case ctrl.name)
End If
End Sub
Hopefully that at least points you in the right direction.

SAP Central Management Console Parameters not aligned

I have been designing Crystal Reports, and publishing them to the SAP Central Management Console, for the past couple of years; but I have never come across this really strange issue before!
The report in question has 7 Parameters:
1 is a static String Parameter,
1 is a static Date Range Parameter
3 are static Number Parameters
1 is a static String Parameter with a pre-defined list of values
1 is a multi-level dynamic String Parameter
All of these parameters work fine when running reports from the Designer application itself, but as soon as it's published to the Central Management Console it all messes up:
If you choose the first Parameter, you get the first parameter input screen.
If you choose the second Parameter, you get the first parameter input screen.
If you choose the third Parameter, you get the second parameter input screen.
If you choose the fourth Parameter, you get the third parameter input screen.
etc
This means that there is no way of selecting the 7th Parameter as it shows you the 6th parameter input screen.
This behavior started when I added two of the static Number Parameters. Before this everything worked fine, and I cannot find online documentation/help which would allude to a Parameter limit in CMC.
Crystal Reports Designer Version: Crystal Reports 2008, Version 12.3.0.601
Central Management Console Version: SAP BusinessObjects Enterprise XI, Product 12.1.0
Thanks in advance for any help!
After investigating I realised that the problem was Central Management Console does not interact well with multi-level parameters.
I changed the multi-level parameter to two separate parameters, and everything is working.

Word 2010 can Field added via QuickParts be given an ID and later referenced in document.Fields collection

I need to add a few fields to a Word 2010 DOTX template which are to be populated automatically with custom content at "run time" when the document is opened in a C# program using Word Interop services. I don't see any way to assign a unique name to "Ask" or "Fill-In" fields when adding them to the template via the QuickParts ribbon-menu option.
When I iterate the document.Fields collection in the C# program, I must know which field I'm referencing, so it can be assigned the correct value.
It seems things have changed between previous versions of Word and Word 2010. So, if you answer please make sure your answer applies to 2010. Don't assume that what used to work in previous versions works in 2010. Much appreciated, since I rarely work with Word and feel like a dolt when trying to figure out the ribbon menuing in 2010.
You are correct in that fields don't necessarily have a built-in way to uniquely distinguish themselves from other field instances (other than its index in the Fields collection). However, you can use the Field.Type property to test for wdFieldAsk or wdFieldFillIn . If this is not narrow enough to ID then you will need to parse your own unique identifier from the Field.Code. For example, you can construct your FILLIN field as:
{ FILLIN "Hello, World!" MYIDENTIFER }
when you iterate through your document.Fields collection just have a test for the identifier being in the string. EDIT: example:
For Each fld In ActiveDocument.Fields
If InStr("CARMODEL", fld.Code) <> 0 Then
''this is the carmodel field
End If
Next
Another alternative - seek your specific field with a Find.Text for "^d MYIDENTIFIER" (where ^d is expression for 'field code')
Let me know if this helps and expand on your question if any gaps.

Displaying a parameter's description value

In Crystal Reports v 11, is it possible to display the 'Parameter Description' value on the report, as opposed to only the parameter value? Whenever I drag the parameter onto the report to display it, only the value is displayed, and I want to print the description.
Note: I'm working in Crystal 11 (XI), not the .NET Crystal Report plug-in.
I agree with Ryan--there isn't a native mechanism to grab these values. A user-function library (UFL) might be an approach worth investigating.
In lieu of that, I handle this a number of ways:
a formula with a case statement to convert the value to a description.
a custom function that does the same a #1; custom functions can be shared w/ other reports via the BOE repository
use a subreport to query a table that can covert the value to a description. store the values in an array in the Detail section (suppressed), then Join() the array in the report footer. if you embed the subreport in its own section, it will expand as needed to accommodate an expansive list
you might be able to adapt #3 to use a list of values exposed by BO's query as a web service (QAAWS), but I haven't experimented with this. If it doesn't have an associated schema document, CR won't be able to use the XML webservice as a data source.
First, Concatenate the parameter value and the description together and delimit the two values using a pipe '|' or other lesser used character
Example:
CustomerID, CustomerName -> 12345|ABC Company
Second Use a Crystal function with an array to display the description side on your report i.e everything after your delimiting character
Numbervar i;
Numbervar j;
StringVar Array z := "";
Local StringVar Array x := split(Join({?My Parameter},";"),";");
j := count(x);
redim preserve z[j];
for i := 1 to j do(
z[i] := right(x[i],Length(x[i])-instr(x[i],"|"))
);
join(z,",")
Third. Create a second function like the one above to return the Parameter value to the left of the delimiter to use as part of the report's Selection Formula**
I don't believe there is a way to directly get at the description (several other posts scattered around the interwebs seem to agree). If you have a small(-ish) number of parameter options, you can just create a formula or function that contains a case-statement that will translate the value to its description.
I got over the shock that Crystal Reports somehow is able to retrieve the description of a parameter but it doesn't expose it to be used in formulas. Being forced to duplicate the definition of parameters and description seems to me bad form, simply because one is not supposed to duplicate things when programming. An alternative hack (besides all the ones listed) would be to make your Values and Descriptions as values of a SQL data source (hardcode them in SQL). Then you can populate your parameter from said data source and you will have the Descriptions available as a field. That way you only have "one version of the truth" that maps your values to your descriptions, although more moving pieces.
See: 1678487 - How to display parameter descriptions instead of parameter values in the Crystal Reports at: https://apps.support.sap.com/sap/support/knowledge/public/en/1678487
There is a new function that can actually be used for displaying the descriptions of a parameter on a report.
Source : https://launchpad.support.sap.com/#/notes/2037542
I will paste the entire document for those users who don't have to access to this page.
A new function GetValueDescriptions() is added in Crystal Reports 2016, to allow user create formula that could operate / display descriptions of selected value for a parameter.
GetValueDescriptions() supports all kinds of parameters (single and multiple, discrete and range). Below is an formula example where {?customerMultiDiscreteAndRange} is a multiple range parameter:
local stringVar range array im := GetValueDescriptions ({?customerMultiDiscreteAndRange});
local numberVar i := 1;
local stringVar out := "";
while i <= count(im) do
(
if (IncludesLowerBound ({?customerMultiDiscreteAndRange}[i])) then
( out := out + "["; )
else
( out := out + "("; );
if (HasLowerBound ({?customerMultiDiscreteAndRange}[i])) then
( out := out + GetLowerBound(im[i]) );
out := out + "..";
if (HasUpperBound ({?customerMultiDiscreteAndRange}[i])) then
( out := out + GetUpperBound(im[i]) );
if (IncludesUpperBound ({?customerMultiDiscreteAndRange}[i])) then
( out := out + "]"; )
else
( out := out + ")"; );
if (i < count(im)) then
out := out + ", ";
i:= i + 1;
);
out;
Also note two new functions - GetLowerBound() and GetUpperBound(), they can be used to get correct lower / upper bound descriptions. These two are especially useful if Maximum() and Minimum() returns swapped descriptions.
Above formula example can be adjusted easily, e.g. to show both the value and descrition, or to satisfy more reporting needs.
To use these functions, upgrade your Crystal Reports to a release where the enhancement has been made.
See the SP Patch Level section for details and available patches.
For SAP Crystal Reports, version for Eclipse:
These functions are supported for runtime only since SP22, with following limitations:
Static multi-range parameters are not supported in SAP Crystal Reports, version for Eclipse runtime, which is the same as before. Dynamic multi-range parameters are supported.
"Value Options" to show description is not supported in the embedded designer in SAP Crystal Reports, version for Eclipse. If you have an existing report designed in SAP Crystal Reports 2016 with parameters' "Value Options" to show description, any modification resaved in the embedded designer will overwrite the "Value Options" to show value. Instead, reports created in SAP Crystal Reports 2016 with the "Value Options" to show description is supported in SAP Crystal Reports, version for Eclipse runtime.
To download the latest Support Packages of SAP Crystal Reports, version for Eclipse:
https://wiki.scn.sap.com/wiki/display/BOBJ/SAP+Crystal+Reports+version+for+Eclipse+-+Downloads

Crystal Reports - Default Parameters

In Crystal reports, you can define default values for the report parameters.
For example, I might have a date range and set a default start of 12/01/2008 and a default end of 12/31/2008.
Is it possible to modify these defaults at runtime? For example:
1 - Default to the first and last days of the current month?
2 - Default to the first and last days of a proprietary company fiscal calendar? (i.e., look it up in a database)
3 - First & Last days of the current year?
You get the point. Is this possible? I'd even be open to a solution that involved running an external application to reach into the reports and modify them, if anyone knows how to do that.
Edit:
To answer the question posed by Philippe Grondier, most of these reports are run from inside an application. I was hoping for something simpler than manipulating the crystal object at runtime; I have my hands full right now with figuring out other parts of that API. I might take a look in the future, though.
Are you planning to run your crystal report from the crystal reports interface or as an add-in embedded in another program (you can for example use the Crystal Reports ActiveX Designer Runtime Support - craxdrt.dll - in VB code) ? In this last case, it is possible to manipulate every object of the report before launching it. Objects such as parameters can then be updated according to your needs.
As a simple example of such runtime update, my report printing routine will allways check if there is a field named "printedBy" in the report. In case this field is found, its value will be settled to the the domain name of the user that requests the report and will be printed out.
At an higher level, you can even reshape the report SQL string to add specific filters that can be inherited from your code. By doing so you might not even need parameters anymore: let your code add the filtering values 'on the fly'
EDIT: some code examples:
(m_rapport is a CRAXDRT.report object, ActiveSession is my current session object)
If m_rapport.ParameterFields.Count > 0 Then
For i = 1 To m_rapport.ParameterFields.Count
If m_rapport.ParameterFields(i).Name = "{?PUB_DateDebutPeriode}" Then
m_rapport.ParameterFields(i).AddCurrentValue CDate(DateValue(sessionActive.dateDebutPeriode))
End If
If m_rapport.ParameterFields(i).Name = "{?PUB_DateFinPeriode}" Then
m_rapport.ParameterFields(i).AddCurrentValue CDate(DateValue(sessionActive.dateFinPeriode))
End If
If m_rapport.ParameterFields(i).Name = "{?PUB_id_Personne}" Then
m_rapport.ParameterFields(i).AddCurrentValue StringFromGUID(clientActif.id_Personne)
End If
Next i
Endif
I also have another function to change report's datasource at runtime, so that reports can be executed on different servers/locations.
Read my posting Crystal Reports: Named-Date-Range Parameters. Maybe you'll be able to leverage this technique for your purposes.