I LOAD P70_NODE_ID from Javascript.
APEX 20.2
then run the following:
apex_util.set_session_state('P70_NODE_ID_OUT', :P70_NODE_ID);
When I show the session I see P70_NODE_ID_OUT and P70_NODE_ID. They both have the correct values
link to another page using the link builder
under item and value:
item P80_STEP_ID value :P70_NODE_ID_OUT
display p80_STEP_ID
I never see a value.
NOTE: The target page is a modal dialog built with the form wizard.
I have tried using a where statement P80_STEP_ID = :P70_NODE_ID_OUT
Still I don't see a value.
Is the problem related to inserting a value from Javascript?
How do I work around this?
Thanks
It turns out that when using redirect to another page in the same application, it uses the values that exist when the page is built and never looks at the values again. As a result, when values change after a page is loaded, the new values aren't used. The following allows you to use changed values when redirecting.
Used advice from the Apex community. This is what worked for me.
This uses apex_page.get_url and the technique you suggested. Tested good.
Javascript that runs when a node is selected in a flowchart:
$s('P72_NODE_ID', tagNum);
$s('P72_NODE_TYPE', selNode.getShape().getId());
$.event.trigger('submitNodeSel');
DynamicEvent
WHEN
event: custom
custom event: submitNodeSel
selectionType: javascriptexpression
javascript expression: document
True Action
Action: set value
set type: PL/SQL Function Body
DECLARE
STEP_DETAIL_URL varchar2(2000);
l_app number := v('APP_ID');
l_session number := v('APP_SESSION');
BEGIN
STEP_DETAIL_URL := apex_page.get_url(
p_page => '80'
, p_items => 'p80_step_id,p80_node_type'
, p_values => :p72_node_id || ',' || :p72_node_type
, p_plain_url => true);
RETURN STEP_DETAIL_URL;
END;
input: p72_node_id,p72_node_type
affected Elements
selection type: item(s)
item(s): P72_STEP_DETAIL_URL
BUTTON
Dynamic Action
execute javascript code
True Action
Javascript
makeDialogUrl( $v("P72_STEP_DETAIL_URL"));
Javascript Code
function makeDialogUrl (url) {
var i;
// replace unicode escapes
url = url.replace(/\\u(\d\d\d\d)/g, function(m,d) {
return String.fromCharCode(parseInt(d, 16));
});
apex.navigation.dialog(url,
{title:'Dialog In
Out',height:'auto',width:'720',maxWidth:'960',modal:true,dialog:null},
"t-Dialog-page--standard", "#STEP_DETAILS");
}
2 should be
under item and value: item P80_STEP_ID value &P70_NODE_ID_OUT.
Note leading ampersand & and trailing dot .
BTW, Apex would have done it for you if you picked columns from the LoV.
Related
I was trying to automate a text submit form using cypress. The 'Create student' button is disabled even after all the fields have been filled
Please see the cypress error
code :
it('should be able to add a new student and update the details, remove from the class and delete the account', function () {
cy.visit(
'https://readingeggs.blake-staging.com/district_ui#/reading/manage-schools/students/195286/new'
)
cy.findByLabelText('First Name').type('ark')
cy.get('#first-name').should('have.value', 'ark')
cy.findByLabelText('Last Name').type('last')
cy.get('#last-name').should('have.value', 'last')
cy.get('[data-test-select-grade]').select('1')
cy.get('#grade-dropdown').should('have.value', '1')
cy.get('[data-test-select-teacher]').select('Lehner, Abbey')
cy.get('#teacher-dropdown').should('have.value', '3068134')
cy.get('[data-test-submit-new-student]').click()
cy.get('#main')
.findByRole('alert')
.should('include.text', `Successfully created a student`)
})
})
Be careful using click({force:true}) as suggested in the error message, there may be another problem that your test will now ignore!
You can first try an assertion that the button is not disabled.
Sometimes the test can run too quickly, and the web page has not yet enabled the button before the test tries to click it.
Adding .should('not.be.disabled') will retry this check for up to 4 seconds, which should be enough time for the page to complete changes.
cy.get('[data-test-submit-new-student]')
.should('not.be.disabled')
.click()
If using .should('not.be.disabled') does not work (I agree, it should be the first thing to try), try adding a trigger event to each input - in case the .type() command is not triggering the validation change.
cy.findByLabelText('First Name').type('ark').trigger('change')
cy.get('#first-name').should('have.value', 'ark')
cy.findByLabelText('Last Name').type('last').trigger('change')
cy.get('#last-name').should('have.value', 'last')
cy.get('[data-test-select-grade]').select('1').trigger('change')
cy.get('#grade-dropdown').should('have.value', '1')
cy.get('[data-test-select-teacher]').select('Lehner, Abbey').trigger('change')
cy.get('#teacher-dropdown').should('have.value', '3068134')
cy.get('[data-test-submit-new-student]').click()
If still no joy, use .click({force:true})
By the way, cy.get('[data-test-select-grade]').select('1') looks a bit suspicious. The select command can take a display value as a string or a position value as a number. The screenshot shows "K" is selected, so I would expect either of these to work
cy.get('[data-test-select-grade]').select(1) // number passed
// or
cy.get('[data-test-select-grade]').select('K') // string passed
One option would be to use {force: true} with click().
it('should be able to add a new student and update the details, remove from the class and delete the account', function () {
cy.visit(
'https://readingeggs.blake-staging.com/district_ui#/reading/manage-schools/students/195286/new'
)
cy.findByLabelText('First Name').type('ark')
cy.get('#first-name').should('have.value', 'ark')
cy.findByLabelText('Last Name').type('last')
cy.get('#last-name').should('have.value', 'last')
cy.get('[data-test-select-grade]').select('1')
cy.get('#grade-dropdown').should('have.value', '1')
cy.get('[data-test-select-teacher]').select('Lehner, Abbey')
cy.get('#teacher-dropdown').should('have.value', '3068134')
cy.get('[data-test-submit-new-student]').click({force: true})
cy.get('#main')
.findByRole('alert')
.should('include.text', 'Successfully created a student')
})
I am working on Forms 6i on a very old software.
There is a requirement to add 3 List Item (Combo Box) to the form.
If the value in List Item X is changed, then upon WHEN_VALIDATE_ITEM, I need to change the value on List Item Y.
Here is the code but it's not working.
BEGIN
IF :PIH.TEXT_ITEM1544='Book' THEN
Copy('Own Use',Name_In('PIH.TEXT_ITEM1546'));
END IF;
END;
There are no errors in compilation, but I believe that when I select the value Book and press enter or tab and go to another field, nothing is triggered.
Any help would be really appreciable.
What do you want to do exactly? If you want to assign the value 'Own Use' to the item PIH.TEXT_ITEM1546 you can do it with:
:PIH.TEXT_ITEM1546 := 'Own Use';
Or with:
Copy('Own Use','PIH.TEXT_ITEM1546')
The statement you're using:
Copy('Own Use',Name_In('PIH.TEXT_ITEM1546'));
is trying to copy the value 'Own Use' to the item referenced by PIH.TEXT_ITEM1546, i.e., it's trying to copy the value to an item named as the value stored in the item PIH.TEXT_ITEM1546.
The Name_In function gets the value of the specified item.
I've one grid created on second page of page frame and linked to .PRG file for each time activate on different page. Under Activate events, each grid's column defined its own member class created under .PRG file.The problem is I couldn't able to access to each member control of grid's columns even I tried to change it but it will remain same class created under individual page's activate events.
I won't initialise the gird's column control base class on grid's init event because I need to set additive access to different .PRG file When access on different page. This problem of failed to access column member or control of grid won't be exists in form when I initalised grid's member control under grid's init events. BTW,i'm using vfp 6.
My Code under Page item Activate Events
set procedure to
set procedure to cn_pro additive
for count = thisform.page_.pages(thisform.page_.activepage).grid_list.columncount to 1 step -1
column_ = "column" + alltrim(str(count))
thisform.page_.pages( thisform.page_.activepage ).grid_list.removeobject( "&column_")
next
with thisform.page_.pages(thisform.page_.activepage).grid_list
.addobject("column1","column")
.columns(1).visible = .t.
.columns(1).bound = .t.
.columns(1).width = 75
.columns(1).header1.alignment = 2
.columns(1).header1.caption = "Mod_Qty"
.columns(1).removeobject("text1")
.columns(1).addobject("btn_qty","btn_quan")
.columns(1).currentcontrol = "btn_qty"
.columns(1).btn_qty.visible = .t.
.columns(1).btn_qty.caption = "Mod Qty"
.columns(1).sparse = .f.
endwith
create cursor tmpcur(btn_qty logical null)
use in select('tmpcur')
use in dbf('tmpcur') in 0 again alias tmpcur_
use in tmpcur
thisform.page_.pages(thisform.page_.activepage).grid_list.recordsource = ""
thisform.page_.pages(thisform.page_.activepage).grid_list.recordsource = "tmpcur_"
thisform.page_.pages(thisform.page_.activepage).grid_list.refresh()
**My class code in cn_pro.PRG file(Same example 1 problem)**
define class frm as form
procedure keypress
LPARAMETERS nKeyCode, nShiftAltCtrl
for each frm_ in _screen.forms
if alltrim(frm_.name) == "MAIN"
scan
with frm_.page_.pages( frm_.page_.activepage ).grid_list
**=>Example is here I've two record inside the grid,
**=>I want to change the property of button or access on it.**
.column1.btn_qty.enabled = .f.
**=>It will return Error message said "unknown member btn_qty" How to fix it?**
endwith
endscan
endif
endfor
endpro
enddefine
**My class code in cn_pro.PRG file(Same example 2 problem)**
define class frm as form
procedure keypress
LPARAMETERS nKeyCode, nShiftAltCtrl
for each frm_ in _screen.forms
if alltrim(frm_.name) == "MAIN"
scan
with frm_.page_.pages(frm_.page_.activepage).grid_list
**=>Example is here I've two record inside the grid,
**=>I want to change the property of button or access on it.**
.removeobject('column1')
**=>Remove entire column1 contained with** commandbutton "btn_qty"
.createobject('column1','column')
.column1.bound = .t.
.column1.text1.visible = .t.
.column1.sparse = .f.
.refresh()
**=> Previous CommandButton on column1 should be changed and
** replace with text here but It won't change and still be
** same commandbutton.Why, How to fix it?**
endwith
endscan
endif
endfor
endpro
enddefine
Hopefully anyone could solve my problem here.Thanks!
If i understand correctly, your approach will not work. You don't need to remove columns, you need to add/remove objects to the column and then set the columns current control property to the control you want.
If you want a variety of different controls to display for the same column, then you set the dynamiccurrentcontrol property to an expression that will look at a value and then return the name of the column.control that you want to display dependent upon the logical comparison in the expression.
I think I've ready found the solution, the reason why it unable detect button(control members fo grid) because it is created right after return focus to main form when you have grid created on page frame.
m.result = .t.
frm_.page_.pages(frm_.page_.activepage).btn_print.setfocus() =>to set it focus for later trigger btn_print's gotfocus
=>event,which will be able to change property's of member control of grids.
this.release =>exit "frm" class
Coding for btn_print gotfocus
if m.result=.t.
m.result = .f.
with this.parent.gid_list
.columns(1).btn_qty.enabled = .f.
endwith
endif
Struggle me for one day more until i could find out the reason and solution.
I Guys
In forms I use,
onKeyUp="this.value = this.value.toUpperCase()"
To force upper-case. However for such as name fields. How do you force the upper letter to be upper-case only while the user is typing. I know INITCAP will do that but need to do as user is typing, if that makes sense.
Any help will be much appreciated.
This is a javascript question then, not and Oracle or APEX question. It shouldn't make any difference what the environment is as long as you have access to the DOM events with javascript functions. e.g. http://www.w3schools.com/jsref/event_onkeyup.asp
If you do a search there are lots of examples to Initcap a string in javascript, just pass in the string and reset the item in the dom e.g.
function capitalizeEachWord(str) {
return str.replace(/\w\S*/g, function(txt) {
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
});
}
I tried to solve this problem.
For that I created JavaScript function which check first letter capital ,if not then it display alert and revert text.
please check following code for text item:
function checkUpper()
{
var x = $x("P6_TEXT");
if (x.value.trim().substring(0,1) != x.value.trim().substring(0,1).toUpperCase()) {
alert ('First letter Must be in upper case');
x.value = x.value.trim().substring(0,x.value.trim().length-1).toString();
}
}
And set item P6_TEXT attribute as
onKeyUp="checkUpper();"
In the field custom attributes put this JS code:
onKeyUp="this.value = this.value.substring(0,1).toUpperCase()+this.value.substring(1).toLowerCase();"
You could use content modifiers from Universal Theme https://apex.oracle.com/pls/apex/apex_pm/r/ut/content-modifiers
I needed text in a page item to be uppercase and under Advanced I set the css classe to
u-textUpper
u-textInitCap - Sets The First Letter In Each Word To Use Uppercase
This one is really simple. I've got a <select> and I want to update some internal state based on the selection. No need to redisplay anything. The problem is that after the selection and the AJAX request have been made, the list loses its contents.
renderContentOn: html
|value myId|
html form with: [
html select list: #('one' 'two' 'tree' 'four' 'five');
id: (myId := html nextId);
callback: [ :v | value := myId ];
onChange: (
html prototype updater
triggerFormElement: myId;
callback: [:h | value "do something with the value here"];
return: false
).
]
The #updater needs an DOM ID of the element to update. If you fail to provide an ID, it default to this, the DOM element triggering the event. Thus, you end up with an empty list. If you do not need to update something you should use #request instead of #updater. If you want to update something you need to provide a valid ID using #id:.
Read the section AJAX: Talking back to the Server of the Seaside Book, it explains AJAX in great detail.
Because the updater replaces the html of the element it was defined on with the content generated by the callback and your callback does not generate any html, the list is empty, I think.