Monday, February 18, 2019

Awake after so long ...?

I'm considering digging into the newer versions of lims, if my interest holds. 

It amazes me how many questions and visits this site receives after so long.

Monday, February 25, 2013

Check before jumping

I took this from the client script utilities in the Validators.

function csValidateFormExists(strValue) {
    try {
        var ids = lims.CallServer("Enterprise_Data_Providers.FormProvider.GetIds", strValue.Split("."));       
        return ids && ids.length >= 3;
    }catch(e) {
        return false;
    }
}

I find it very useful to check to make sure the form I'm about to call actually exists.  Especially when I am jumping applications.

Tuesday, February 19, 2013

TSQL function "IDENT_Current"

I find this TSQL function to be terribly useful, especially in server calls where I need to insert a record and then need its Origrec.

To use it, do an insert into a table


bSuccess := SqlExecute("INSERT INTO TABLENAME...");

then, to find out the Origrec of the row you just entered, use:

 iOrigRec := SqlExecute("SELECT IDENT_Current('TABLENAME')");


Form.isDirty

Found this one the other day.  Its a Boolean variable that flips when something changes on the form.  The problem is it seems almost everything let's it change.  Honestly I prefer to just set a variable I can control, usually as a form variable or navigator variable.  It just seems easier.



Tuesday, February 12, 2013

Excellent SQL Tips

I really love this article and thought I would share.

I noted at least half of these errors in the default code that came with Starlims' product.

Not a slam so much as to how easily they slip in.

http://www.simple-talk.com/sql/t-sql-programming/ten-common-sql-programming-mistakes/


Monday, February 11, 2013

Hiding Shell Toolbar Items

From time to time I would need to hide different shell toolbar items.  Typically I did so based on the user's permissions or by what window they were in.


   oWindow:=LimsApp("Shell");
   oToolBar:=oWindow : TOOLBAR;

   Dummy:=oToolBar : HIDEITEM(102);     /*Database Connection;
   Dummy:=oToolBar : HIDEITEM(104);     /*User Action;


Item 101 = Closed Starlims
Item 102 = Database Connection
Item 103 = Printer
Item 104 = User Action
Item 105 = NOTHING
Item 106 = Search
Item 107 = Sort
Item 108 = Change View
Item 109 = Copy to Clipboard
Item 110 = First Record
Item 111 =NOTHING
Item 112 =Previous Record
Item 113 = Next Record
Item 115 = Last Record
Item 116 = Mark All
Item 117 = Unmark All
Item 118 = Refresh
Item 119 = Reload
Item 120 = Timesheet (could be local for my system)


You can also ShowItem(), DisableItem() or EnableItem() as well using the same format as above.

Sunday, February 10, 2013

PrmCount()

It goes without saying that if you employ ExecFunction() statements in your code you are going to pass parameters.  Knowing that the parameters you expect were passed becomes important and so is the PrmCount().

Not only will it check and ensure the correct number of parameters were passed, it can be used to create stems of programming logic based off that value as well.

Usually this was something I wrapped in a Case statement.  for example:

:BEGINCASE;
     :CASE PrmCount() = 1;

     :CASE PrmCount() = 2

etc., etc.

This let me count the number of parameters passed and perform logic based on that number.  Very useful to catch errors and make sure you are using the correct passed values.

The order, by the way, is the same order you declared the parameters.  So, if PrmCount() = 1 then it matches the first parameter declared after the :PARAMETERS label.