Modify global variable defined outside of table inside the table - birt

I have a persistent global variable set outside an inner table and inside that inner table I am modifying the value then I want to retrieve it after the inner table is done doing its functionality. I noticed when I retrieve the value inside the inner table and append the necessary then display the new values inside the inner table row it shows but when I want to retrieve variable after table modifies, the data I use to the global doesn't show the modified variable, is there maybe something I am doing wrong.
Any kind of help is highly appreciated.
Thanks in advance.

You should post your scripts and from which method event they are invoked, it would help to pinpoint the precise cause of the problem.
As you describe it, most likely your inner Table is updating this variable through an "onRender" event, it would explain why this is not available in other elements. When we deal with persistent variable we should never update its value in render events, unless being very comfortable with BIRT elements lifecycle.

Related

Servicenow - Service Catalog Reference Field - Insert different column than the display value

Let me describe my problem:
I have a table for all my IT-Services. I reference to this table more than once, for different purposes. Most of the time I need to reference to the name of the service. That's why I keep the name as displayed value.
One Column of that table is a service_id (custom field) which is for example "Service_004". Now in a catalog request Item the User has to fill in the service_id in a reference field.
But since I have the name as displayed value, and I need it in other forms, I am unable to reference to the service_id.
Using the variable attributes field I managed to let the service be found using the autocomplete function. But in the reference field I still get the servicename. I know that I can change the display value in the dictionary, but this breaks other functions. So what I need is to change the display value just for one reference field.
Also I tried to create a new table called IT-Services2 with reference to my table IT-Services. Then I switched the display to true in the new table for my service_id, but this will even change it in the parent table.
Perhaps an onChange client script utilizing g_form.setLabelOf() ?
http://wiki.servicenow.com/index.php?title=GlideForm_(g_form)#setLabelOf
Maybe I'm not fully understanding your question...
I ran into this issue before, what you can do is create select box variable and use an on load client script to populate the list with the service_id(s) from the table you are referencing.
I would write a script include to pull the data from the table and call it from the client script via GlideAjax.

Getting a dbid by table name

As far as I know, all QuickBase API calls are called using the following syntax: http://<quickbase>/db/<dbid>?
Is there a way to get the dbid field without navigating to that database table within QuickBase?
If the above is not possible, would anyone recommend anything other than creating another table that stores the IDs of the tables you want?
With the latter method, I believe I would only need to store one dbid and could pull down the rest (which I believe would still need to be user entered, but would be better than requiring them to change the code).
Thanks for the help!
API_GetSchema will return the list of dbids.
https://www.quickbase.com/db/<yourApplicationId>?act=API_GetSchema&apptoken=<yourApplicationTokenId>&fmt=flat

Concrete 5 ADODB update and insert duplicate primary key

I'm creating a new package for Concrete 5 (5.4.0+). Inserting a new block works perfectly. But when I edit an existing block, it tries to INSERT again when I click 'save', instead of UPDATE.
The two fields on the database that affect this are bID and eID. Both are non-auto-incrementing INT(10) default none NOT NULL.
The values are passed in an associative array $args in the controller and I'm calling the parent save method with Parent::save($args);
Any help/input would be appreciated. PS: I have looked over this on the net and the C5 forums did turn up some stuff which I tried, mostly relating to the database fields, but I still get the above error. I don't want to overwrite the ADODB save() method if possible.
--- EDIT ---
Perhaps I'm looking at this all wrong. Let me say what I'm trying to achieve. I need the eID to remain 37 (for example) across multiple edits of the block. The bID can increment away AFAIC.
How do I get the eID to remain 37 on edit, but increment by 1 on creation of a new instance? Make sense?
A second table references the eID field, and edited instances of an entry on this table must have the same eID unless a new instance is created. Sry - clear as mud I know.
Are you saying you get a new instance of the block appearing on your page, rather than a new version of the existing one? I don't think the problem is with there being a new record inserted in your table, since new records are normally created when you edit a block. C5 keeps the older version of the block.
The custom blocks I've done have never required a call to the parent save method. You just need an edit form that collects the data and designates which database field it corresponds to, and the parent controller knows what to do with it when the form is submitted.
For example, if you have a text field in your block table called "firstname" that you are updating, you would add a line to your edit.php file like this:
<?php echo $form->text('firstname', $firstname, array('style' => 'width: 320px'));?>
My block editors contain little else than this, other than html/CSS stuff to add labels and make the form look better. The $form object takes care of everything else.
One thing that really helped me understand blocks and block controllers was to download and install the "designer content" add-on. It's free. You can use it to build some custom blocks, then look at the code it generates to perform various functions.
So I looked into the existing packages to duplicate this funcitonality and my question has evolved into this: PHP Concrete 5 Pass Variables to Add.php
Follow the rabbit ;)

Using Linq SubmitChanges without TimeStamp and StoredProcedures the same time

I am using Sql tables without rowversion or timestamp. However, I need to use Linq to update certain values in the table. Since Linq cannot know which values to update, I am using a second DataContext to retrieve the current object from database and use both the database and the actual object as Input for the Attach method like so:
Public Sub SaveCustomer(ByVal cust As Customer)
Using dc As New AppDataContext()
If (cust.Id > 0) Then
Dim tempCust As Customer = Nothing
Using dc2 As New AppDataContext()
tempCust = dc2.Customers.Single(Function(c) c.Id = cust.Id)
End Using
dc.Customers.Attach(cust, tempCust)
Else
dc.Customers.InsertOnSubmit(cust)
End If
dc.SubmitChanges()
End Using
End Sub
While this does work, I have a problem though: I am also using StoredProcedures to update some fields of Customer at certain times. Now imagine the following workflow:
Get customer from database
Set a customer field to a new value
Use a stored procedure to update another customer field
Call SaveCustomer
What happens now, is, that the SaveCustomer method retrieves the current object from the database which does not contain the value set in code, but DOES contain the value set by the stored procedure. When attaching this with the actual object and then submit, it will update the value set in code also in the database and ... tadaaaa... set the other one to NULL, since the actual object does not contain the changed made by the stored procedure.
Was that understandable?
Is there any best practice to solve this problem?
If you make changes behind the back of the ORM, and don't use concurrency checking - then you are going to have problems. You don't show what you did in step "3", but IMO you should update the object model to reflect these changes, perhaps using OUTPUT TSQL paramaters. Or; stick to object-oriented.
Of course, doing anything without concurrency checking is a good way to lose data - so my preferred option is simply "add a rowversion". Otherwise, you could perhaps read the updated object out and merge things... somehow guessing what the right data is...
If you're going to disconnect your object from one context and use another one for the update, you need to either retain the original object, use a row version, or implement some sort of hashing routine in your database and retain the hash as part of your object. Of these, I highly recommend the Rowversion option as well. Using the current value as the original value like you are trying to do is only asking for concurrency problems.

Default Sort Column with Linq to SQL

I am in the process building myself a simple Linq to SQL repository pattern.
What I wanted to know is, is it possible to set a default sort column so I don't have to call orderby.
From what I have read I don't think it is and if this is the case what would recommend for a solution to this problem.
Would the best idea be to use an attribute on a partial class on my model?
the default order is the clustered index on the table you are pulling from.
What are you wanting to sort on (without sorting on) ?
If you needed something other than having it sorted by the primary key, you could look at supplying a select statement for the table instead of using the runtime generated statement. Look at the properties on the table in the designer -- you should be able to override the runtime generated select, delete, and update statements. I don't personally recommend this, though, since I'm not sure how it will interact with other orderings. I think the intent is more along the lines of allowing you to use stored procedures if you want.
Another alternative would be to create a table-valued function or stored procedure that does the ordering the way you want and has the same schema as the table. If, in the designer, you drag this onto the table, you get a strongly typed method on the data context that you can use to obtain those entities according to the definition of the function/procedure instead of the standard select. Personally I think this introduces fewer maintenance headaches because it makes it more visible, but you do have to remember to use the method instead of the Table property for that entity.

Resources