New button to change SQL in realtime

I have a form app with button ‘Show Latest’ (as attached pic),
how could i show only LATEST row (only display 1 row) instead of all?

Screen Shot 2014-07-20 at 9.34.36 am.jpg

i found this macro
http://www.scriptcase.net/docs/en_us/scriptcase-macros/scriptcase-macros#sc_where_filter

but stated it only work for ‘GRID’ app.
hope someone could enlighten me coz it’s one of the critical function i need to create my app.

hi,

did you try using SQL LIMIT 1?

hi, i think you misunderstood my question :stuck_out_tongue:

as you can see, i have a field ‘address type’, i could have 5 HOME addresses, 2 OFFICE addresses, they are all having different effective date.
i would like ‘Show Latest’ clicked, it reflect latest home address and latest office address.
So, using SQL LIMIT 1 will not work coz it doesn’t work since it hardcoded to only return 1 row.

What i am looking for, is a method to change “Where clause” definition in form app when the button clicked

Thanks for your help but it jz does’t resolve my issue :s

Yes, it is the same, in button itself you have to put some code or java code, which i’m not aware of it :frowning: but the idea of LIMIT 1 should be also useful as you can limit those displayed record to 1 only when displayed, which is AFAIU is what want to do

I guess many guys here can help in this, i am not that advanced actually, just trying small small :slight_smile:

Mike

Hi mike, I am glad you have been actively help. I am sure ideally it should work IF sc have provide such API or macro, which I comb through and yet can’t find the suitable code.

I am also hoping some senior can guide me how to achieve it coz it look very basic and yet I couldn’t figure out in sc way :frowning:

yes, and your way seems interesting, please let us know if you could success for sharing info sake :slight_smile:

good luck

dear gurus,

i have been stuck here for more than 24 hours :frowning:
anyone can give a helping hand? :slight_smile:

Thank you

Hi,
I suggest you use two buttons: ‘Show all’ and ‘Show latest’ to be able to switch back and forth.

In SQL -> Where Condition: [glo_where] //global variable that contains your where clause.

In onScriptIni:
if(!isset([glo_where])) //to make sure we have a valid where clause
{
[glo_where] = ‘1 = 1’;
}

Code for ‘Show latest’ button:
[glo_where] = “the where clause to show the latest addresses”;
sc_redir(hcm_person_address,glo_where=[glo_where],’_self’); //call the form itself with the new where clause

Code for ‘Show all’ button:
[glo_where] = “1 = 1”;
sc_redir(hcm_person_address,glo_where=[glo_where],’_self’);

In the onLoad event you can hide and show the correct button depending on your [glo_where] variable.

Hope this helps.
jsb

[QUOTE=jsbinca;25266]Hi,
I suggest you use two buttons: ‘Show all’ and ‘Show latest’ to be able to switch back and forth.

In SQL -> Where Condition: [glo_where] //global variable that contains your where clause.

In onScriptIni:
if(!isset([glo_where])) //to make sure we have a valid where clause
{
[glo_where] = ‘1 = 1’;
}

Code for ‘Show latest’ button:
[glo_where] = “the where clause to show the latest addresses”;
sc_redir(hcm_person_address,glo_where=[glo_where],’_self’); //call the form itself with the new where clause

Code for ‘Show all’ button:
[glo_where] = “1 = 1”;
sc_redir(hcm_person_address,glo_where=[glo_where],’_self’);

In the onLoad event you can hide and show the correct button depending on your [glo_where] variable.

Hope this helps.
jsb[/QUOTE]

Hi jsb, i believe your code could work. Let me try later :slight_smile:
Will your code work if my address app is use as ‘child app’?

I hope SC developer can hear my voice, there should be a feature allow button to manipulate the GRID/Form

How would SC redirect if the redirection code is trigger from child app INSIDE a master app?
will it refresh the child app section? or even the master app will refresh as well?

If master app redirect, it would not be correct behavior i want

It doesn’t show expected result after configured as per jsb said
https://docs.google.com/document/d/175mP3azQ58u8IwkNR64-7Xkcin65lFQmhU319-r8fwQ/edit?usp=sharing

[QUOTE=weilies;25274]It doesn’t show expected result after configured as per jsb said
https://docs.google.com/document/d/175mP3azQ58u8IwkNR64-7Xkcin65lFQmhU319-r8fwQ/edit?usp=sharing[/QUOTE]

That’s expected behaviour. Just click on button.
Scriptcase wants a value for your global variable [glo_where] which hasn’t been set yet.
That’s what the if-structure in onScriptInit is for.

I suggest you get the functionality of the form you want/need working and then do the next step and include it
in a master/detail scenario. And no, it will not redirect your master. :slight_smile:

jsb

Hello,

I will discuss your suggestion with our team.

regards,
Bernhard Bernsmann

[QUOTE=bartho;25290]Hello,

I will discuss your suggestion with our team.

regards,
Bernhard Bernsmann[/QUOTE]

Hi Bernhard, thanks for the consideration. hope you can let us know when will it be out (if possible)
i manage to make it work with jsb’s suggestion, THANKS!

But to create a large scale app, i design my app to have multiple master-detail (with the show all/latest feature), so lots of customization needed
If SC deliver such macro to cater for form app, it save lots of time & coding

[QUOTE=jsbinca;25266]Hi,
I suggest you use two buttons: ‘Show all’ and ‘Show latest’ to be able to switch back and forth.

In SQL -> Where Condition: [glo_where] //global variable that contains your where clause.

In onScriptIni:
if(!isset([glo_where])) //to make sure we have a valid where clause
{
[glo_where] = ‘1 = 1’;
}

Code for ‘Show latest’ button:
[glo_where] = “the where clause to show the latest addresses”;
sc_redir(hcm_person_address,glo_where=[glo_where],’_self’); //call the form itself with the new where clause

Code for ‘Show all’ button:
[glo_where] = “1 = 1”;
sc_redir(hcm_person_address,glo_where=[glo_where],’_self’);

In the onLoad event you can hide and show the correct button depending on your [glo_where] variable.

Hope this helps.
jsb[/QUOTE]

hi jsb,

i realize there is a bug if i try to manipulate the search, the rows reduced (since i only retrieve latest rows), it returned only 3 rows but end up the pagination ([1 to 3 of 6]) doesn’t update and confused the pages are incorrect

bug-pagination not refresh when rows changed1.jpg

bug-pagination not refresh when rows changed2.jpg

Hi,
it’ll be most likely your SQL statement(s). Did you try it on your database to see if it returns the correct records?.

jsb

Yup, the SQL is absolutely correct :slight_smile:
That’s why the row reflected only the latest row for each address type.

but it seems like a SC bug for me coz it’s only the pagination not working