I need to run a piece of Java code which builds a complex SQL query. I know how to call the Java methods from JavaScript in BIRT but how can I get a pointer to the current DB session/connection?
If you modify the onCreate event of your Data Set, you can do this on the report and leave BIRT to control the DB connection. Do the following:
Select your Data Set on the Data Explorer window
Select the scripts tab along the lower edge of the canvas area of Eclipse
Select the "onCreate" event from the drop-down list of available events along the top
Work your query-building magic in the editor, using JavScript. You can import your existing POJO that build your query out using the "Packages" construct.
Once your POJO has built the query, return it to the script and set "this.queryText" equal to the resulting string.
This will ensure the data set executes the new query, not the one used to create the data set.
The only gotcha to watch out for is that the query you set in the script must return the same number of columns and have each column be named the same as in the default configuration and share the same data type. How the individual colums get populated is up to the SQL, how the resulting data set looks must me uniform.
Good Luck!
Related
I have a score entry page on a PHP-based website. It uses a DB query to retrieve the player’s Name & DB ID into a PHP array variable, then loops around the returned data to create an HTML <select> dropdown list.
This has now become too long… especially when entering on a mobile device (on iOS its even worse with that scroll wheel implementation they use - I dont even know what it looks like on Android!)
So I have a PHP array with the Name & ID fields in it.
I would like to convert this to filter a dynamic dropdown list as characters are typed in by the user.
I am novice at Javascript and it's nuances, though understand the principles of the language. The DOM model and other things I am also not very familiar with. I expect to use an onChange() function on the <input> textbox(?).
But how do I either tie that back to my existing PHP array variable? Or copy this variable “across” to the JS function?
I have changed the underlying DB to a NoSQL version (MongoDB). The bulk of tutorials, blogs, etc, for “AJAX Live Search” or equivalent seem to be centred around MySQL (which I previously used…)
The esiest approach would be usage of some js library, which can do what you need.
In my experience this should work for you: https://selectize.dev/
It combines select with text input, where text input is only used to seach in the select and hides unmatching records from it.
I'm trying to build a custom UI control in alfresco to display the associations of an object type that I have.
Basically I have two object types; Code, which is a key value pair, and CodeScheme which contains multiple child associations to codes, it's essentially a mirror of a map structure I have in a different system.
The problem I have is that the codes are automatically generated, so they get the UID names, whereas really I'd like to present them as 'key=value', 'key=value', etc (ideally I'd like to present it as a table).
I've already created a custom control and added it to share-config-custom, and confirmed that the configuration is working correctly. What I'm not really clear on now is:
a) How to attach a javascript to the control so that I can process the association data.
b) How to get hold of the codes in javascript, and read their properties.
I'm just looking for a push in the right direction.
Thanks :)
One idea would be to use a form filter. Your form filter could iterate over the child references, fetch each child node, grab the data you want to display and then add one or more new properties with that data.
Then, your form control is hooked to the fields your form filter dynamically added to the form data. It can then read and display the data as needed.
Without a form filter I think you'd have to use JavaScript to parse the child association refs and use AJAX calls to fetch each child's node data, then format that as needed. The form filter idea would be less traffic from the browser.
I wrote some code in javascript that manipulates field info for my contact form. The code is triggered at OnLoad and OnSave. It works well but the company has 5000+ records that need this code to be applied to it.
Is there a way to write code or plug-in or workflow that would simply load the record and then close it that I could use on all records to apply the javascript or do I have to load each record individually?
You could do one the following depending on what you find the easiest:
Console Application (Personal Preference and the easiest) - Get the record unique numbers if you have something set up or GUIDs of the records
you want updated
Plugin (Some sort of record update required to trigger your logic) - add a throw away field - Register the plugin on update of the throw away field, use bulk update and update the field on all the records you want the plugin to run against. Delete the throw away field.
Workflow (custom workflow activity or out of the box depends on the complexity of the manipulation, no record update required to trigger your logic) - Create a workflow/custom workflow activity and run it against all the records - it will probably take an eternity for you to get all 5000 updated at a maximum of 250 a go.
It sounds like one of the easiest ways to do what you want is to simply export the desired records and fields, and then manipulating them in Excel. You would apply the same logic in Excel as you have in your form JavaScript.
Once you're done, just import them back into CRM and the existing records should be updated.
The most important thing to pay attention to is that you export only after selecting the option "Make this data available for re-importing by including required column headings".
Hi peeps on stackoverflow,
Product: CRM2011, should be latest roll-up
I'm currently trying to get the following to Work:
- A custom CRM form has been made. This form contain the 'Notes' tab. I would like to dynamically 'expand' this IF and only IF the 'Notes' tab contains notes data. I'm trying to do this through JavaScript loaded into 'Form Libraries'. I can easily 'expand' the notes field but I'm having serious trouble determining if the 'Notes' tab contains notes data.
I can understand that accessing the 'notes' data through the DOM is not a good idea so I've tried through XRM. Looked through https://msdn.microsoft.com/en-us/library/gg334351(v=crm.5).aspx to see my options. But I can't seem to get to one where I can access 'notes' and base the expansion of the notes field on if there is data or not in 'notes'.
Is this possible? I'm looking forward to hear from you and thank you very much.
Notes are their own entity type, entity logical name is Annotation, that is why you won't find the notes data within Xrm.Page. I'm making some assumptions here, but if you've set up this custom entity to follow standard conventions, any notes on that record will be separate Annotation records with a reference to the custom entity record. using the sdk.jquery.js script provided with the SDK you can do a query on Annotation records that reference the record you are currently on. That would be a supported way to determine if the record has notes. Using the OrganizationData.svc endpoint you would have an OData query that looks something like this
AnnotationSet?$filter=ObjectId/Id eq guid'34d19133-c0ec-e311-b39c-6c3be5bd2b14'
The guid value there would be the guid of the record you are currently on, which if you haven't already acquired within your script, you can get it pretty easily with something like this
window.parent.Xrm.Page.data.entity.getId().substring(1, 37)
or without the window.parent prefixing it
I am trying to display different images based on data returned. I am running into the following issues
DataSet is not available on the image control for me to make decisions based on the column information. I am using a grid layout (no tables)... Think of a letter
I tried to create report level variables and assign it the value from dataset during the onFetch event. However, that assignment does not happen.
I have tried both
rptvar = dataSetRow["colname"]
rptvar = Row["colname"]
I have confirmed that onFetch event does get called using Javascript debugging (see http://www.lebirtexpert.com/wordpress/2010/08/)
Please let me know how to access dataset columns to dynamically create the image URI
There's a post on the BIRT world blog that should be very useful to you:
http://birtworld.blogspot.com/2010/09/birt-image-report-item.html
Kudos to Mr. Weathersby!