Solved

Calculating Custom Fields - Apps 8


Userlevel 4
Badge +9

Hi

I have created 3 new custom numeric fields, 2 will be manual entries and the 3rd I would like to add the numbers from the first 2 fields. Is this possible in Apps 8?

If so does this need to be done via a custom event? Would be much appreciated if it is possible for some to send a screen shot of how. Below is a screen shot of the fields I am referring to, and the one circled is the field I want the calculation to appear.

 

icon

Best answer by paul harland 25 August 2020, 15:40

View original

21 replies

Userlevel 5
Badge +8

Hi
You can make the first two areas a permanent sandbox, write a function in the field you add. 3. and show the total value of the two areas.


create function 

function sum_deger  (source_ref1  IN number , source_ref2  IN number  )RETURN NUMBER
is
source_ref1_ number;
source_ref2_  number;
deger_ number;
BEGIN
source_ref1_  := source_ref1;
source_ref2_  := source_ref2;
deger_ := 0;

SELECT  source_ref1_ +  source_ref2_   deger_ FROM dual  t 
f deger_ is null then
return   0 ;
else   
return deger_ ;
end if;
end sum_deger;

Userlevel 4
Badge +9

Hi

Sorry to be a pain but I am not great in this area, as you may have guessed. When you say ‘write a function’, is this a PL/SQL custom event?

Also just to check, is a ‘permanent sandbox’ just a standard persistent custom field?

Many thanks

Hayley

Userlevel 5
Badge +8
Virtual areas are only worth to see.permanent fields are used for data usage.You can collect two permanent field values ​​with a function on PLSQL and show them in a virtual area.Note: If the value to be displayed in 2 fields is not entered manually and the other fields will continue, you need to make 3 virtual areas.
Userlevel 5
Badge +10

Hi Hayley, what do you mean with “…  I want the calculation to appear.” does this mean the sum or a result of a calculation of the other 2 fields?

Like → Probability * Severity = Initial Risk

 

Userlevel 5
Badge +8

hi

 

Fields are of two types. Value entered Returning value If 3 fields return values, you can virtually open them. If two fields will enter values ​​and one field will return value, It is enough to make two permanent areas and 1 virtual area.

Userlevel 7
Badge +24

hi Hayley

This is pretty easy with an expression read only field

First create fields 1 and 2 as persistent/numeric.

Then create the third field, of type Read only, and use an expression as below

 

result:

 

However, note that the above does not handle nulls very well.

In SQL, (1+ null) = null

What you usually want to see is (1 + null) = 1.

 

So it’s best if you put the following into field3; nvl used like this converts a null value into a zero.

 

nvl ( cf$_field1 , 0 ) + nvl ( cf$_field2 , 0 )

 

 

Userlevel 4
Badge +9

Hi Paul,

Thank you so much, this has worked perfectly!!  You have saved my sanity :smile:

Hayley

Userlevel 4
Badge +9

Hi Paul,

Sorry one more question. If I then have a 4th read only field and want this to add up all the numbers in field 3 what would the expression be, SUM doesn’t work. 

Field 3 is being used on a list view and therefore could be multiple lines added, I then want an overall figure showing all the lines added up, is this possible?

Thanks

Hayley

Userlevel 5
Badge +9

Hi

I have created 3 new custom numeric fields, 2 will be manual entries and the 3rd I would like to add the numbers from the first 2 fields. Is this possible in Apps 8?

If so does this need to be done via a custom event? Would be much appreciated if it is possible for some to send a screen shot of how. Below is a screen shot of the fields I am referring to, and the one circled is the field I want the calculation to appear.

 

Wonderful @paul harland ….!!!

Userlevel 5
Badge +9

Hi Paul,

Thank you so much, this has worked perfectly!!  You have saved my sanity :smile:

Hayley

@HayleyG  …...Paul have helped me as well He actually deserves Hero Title   Appreciate @paul harland ….!!!! 

Userlevel 7
Badge +24

Hi Paul,

Sorry one more question. If I then have a 4th read only field and want this to add up all the numbers in field 3 what would the expression be, SUM doesn’t work. 

Field 3 is being used on a list view and therefore could be multiple lines added, I then want an overall figure showing all the lines added up, is this possible?

Thanks

Hayley

 

hi Hayley

SUM is what you need… but you wouldn’t normally put such a field in the row.  Are you putting it in the header?

Userlevel 4
Badge +9

Hi Paul,

Yes the SUM field will be in the header.

Thanks

Hayley

Userlevel 7
Badge +24

Hi Paul,

Yes the SUM field will be in the header.

Thanks

Hayley

ok - i’m not familiar with this module, and I can’t find it (!) anywhere so i can’t give you the table/field names.

However, you are looking for a read-only field, numeric, set to type “Select” and the SQL Statement will look something like

 

select sum(cf$_field3) 

from child_view c

where c.risk_id = :risk_id

 

and then put risk_id into the arguments field

 

 

Userlevel 4
Badge +9

Hi Paul,

Thanks for the above, though I still cannot get it to work. I have used the argument risk_assessment_no rather than risk ID but get an error saying invalid identifier. I have also tried hazard_id but get the same.

The custom field I want to sum is called INITIAL_RISK. I have attached screen shots of the system info for the header and the child screens in risk assessments. Would you be able to tell me where I am going wrong? Is it because there is no field to correlate the hazard with the risk, like a risk assessment number?

Sorry to be a pain.

Hayley

Userlevel 7
Badge +24

hi Hayley,

thank you - based on that, try this:

 

select sum(cf$_initial_risk) 

from risk_hazard h

where h.risk_assessment_no = :risk_assessment

Userlevel 4
Badge +9

Hi Paul,

I have tried that and get the following:

If I try risk_assessment as the argument I get:

 

Userlevel 7
Badge +24

ah! my bad. 

 

replace the view name “risk_hazard h” with risk_hazard_cfv h”

Userlevel 4
Badge +9

That has let me update the custom field but now when I go to publish I get this:

 

Userlevel 7
Badge +24

ugh - that could be tricky.  do you have any other custom fields in the same LU?

you might need some direct support to clear that up

Userlevel 4
Badge +9

Oh no! Yes I did have another custom field on the same LU, I have just removed it though and still get the error. I will raise a support case.

Thank you so much for your help and time with this though, greatly appreciated!

Hayley

Userlevel 7
Badge +24

de nada.  There are some syntactical differences between custom fields framework in apps 8 and 10 which may explain this.

Reply