I have an elementid from another piece of javascript, and I'd like to get the relevant field object (technically I'd like to get the relevant occurrence in order to get another field in the same occurrence but never mind that).
So I can get passed in a string with "ufld:FIELD.ENT.MODEL:INST.3".
So far (since it's one field I'm doing this for), the best bet I have got is looping through
uniface.getInstance("INST").getEntity("ENT.MODEL").getOccurrence(loopcnt).getField("FIELD").getBoundElement().id
and comparing the result to the string passed in to get a match.
Is there a better way to get to the uniface field object from the element ID as a string?
Regards,
Iain
------------------------------
Iain Sharp
Head of Technical Services
Pci Systems Ltd
Sheffield GB
------------------------------
Hi Iain.
If the event happens due to something related to that field or occurrence (e.g. onclick), you could add a webtrigger to the field and use the this object to get the ID or use the API (e.g. this.getParent().getField("NAME") to get a related field. You might need to wrap an occurrence in an Attributes Only field bound to an HTML element if it is occurrence related. If the event occurs outside of Uniface's control then you could probably determine field details from the ID (i'd wrap that functionality in case Uniface changes it in future). The biggest issue you might have if there are multiple occurrences is that for performance reasons the emitted number in the ID doesn't necessarily match the Uniface occurrence number.
Kind Regards,
------------------------------
David Akerman
Principal Solution & Enablement Architect
Rocket Internal - All Brands
------------------------------
Hi Iain.
If the event happens due to something related to that field or occurrence (e.g. onclick), you could add a webtrigger to the field and use the this object to get the ID or use the API (e.g. this.getParent().getField("NAME") to get a related field. You might need to wrap an occurrence in an Attributes Only field bound to an HTML element if it is occurrence related. If the event occurs outside of Uniface's control then you could probably determine field details from the ID (i'd wrap that functionality in case Uniface changes it in future). The biggest issue you might have if there are multiple occurrences is that for performance reasons the emitted number in the ID doesn't necessarily match the Uniface occurrence number.
Kind Regards,
------------------------------
David Akerman
Principal Solution & Enablement Architect
Rocket Internal - All Brands
------------------------------
This is in response to the tinyMCE editor, as used in one of the samples, which is setup 'inline' to work on the same field in multiple occurrences in a DSP.
As such, the javascript of tinyMCS tells me the id of the element it is bound to (an attributes only field linked to a div). (It's firing an onBlur trigger, against the div. I can't override this with the webtrigger, the function is re-assigned after the screen is painted by tinyMCE)
this at the time it is fired is basically the entire window (or undefined, I forget), and therefore useless.
I was aware that the numbers in the element ID do not map to the occurrence all the time, and are therefore also useless for any kind of navigation.
This is why I need to be able to determine the uniface occurrence of an element solely from the ID, to then work backwards to find the other field values in the record.
As I said, currently the only path I have is to loop through all the occurrences of the entity, getting the bound element for that field name, and comparing the id with the one I have been passed, and since I will only be dealing with tens of occurrences, this is probably not a major drain, but I am leary of things which could get exponential on me as they have proven to be the bane of speed, and speed is my major problem in uniface runtimes.
So I was looking for a (hidden from the documentation (or at least from me searching it)), one step method of getting the uniface object associated with an element ID. So as not to re-invent the wheel.
Regards,
Iain
------------------------------
Iain Sharp
Head of Technical Services
Pci Systems Ltd
Sheffield GB
------------------------------