Callout directly call

64 views
Skip to first unread message

Andrea Checchia

unread,
Feb 10, 2017, 3:44:04 AM2/10/17
to iDempiere
Goodmorning everyone.

I wanted to know if it was possible to directly call a callout from a class / model java.
I created a table / mask where I enter a start date and amount of the performed work hours; at this point from the WebUI, once inserted the amount of hours in the field "Qty-hours", is called the callout that calculates me the date completion of work: start date + "Qty-hours".

How can it be done? Instead of using the "BeforeSave" - "AfterSave" etc of the model, as I call directly callout?

Thanks in advance.

Andrea

Hiep Lq

unread,
Feb 10, 2017, 4:08:45 AM2/10/17
to Mohemmed Bilal Ilyas
callout is a function, so you can call it anywhere you have reference of callout.
but how about parameter? 
at least on model you can't get reference to gridtab, gridfield, a parameter of callout.

--
You received this message because you are subscribed to the Google Groups "iDempiere" group.
To unsubscribe from this group and stop receiving emails from it, send an email to idempiere+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/idempiere/dd2b9fd9-ee8f-4b31-b294-da6fa09634d0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Lê Quý Hiệp
Email: hie...@hasuvimex.vn
Skype: admin.hasuvimex

Company: Thanh Hoa Fishery Import - Export J.s.c  (HasuvimexDL 47
Add: Lot E, Le Mon Industrial Zone, Thanh Hoa, Vietnam

Andrea Checchia

unread,
Feb 10, 2017, 4:38:06 AM2/10/17
to iDempiere
Hi Hiep Lq,

thanks for your reply and sorry for my English :-)

Here I shall quote the code where I create an instance of a model, create the data I need and I try to save the model.

I would need, after saving, call callout associated with the class / model in the table.....

Class<?> clazz = MTable.getClass(table);
Constructor co = null;
try {
co = clazz.getConstructor(Properties.class, int.class, String.class);
poTmp = (PO) co.newInstance(Env.getCtx(), 0, null);
 
} catch (NoSuchMethodException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

MColumn col = MColumn.get(Env.getCtx(), po.get_TableName(), columnName);

if (col.getAD_Reference_ID() == DisplayType.Date || col.getAD_Reference_ID() == DisplayType.DateTime || col.getAD_Reference_ID() == DisplayType.Time) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    Date parsedDate;
try {
parsedDate = sdf.parse(value.toString());
poTmp.set_ValueOfColumn(columnName, new Timestamp(parsedDate.getTime()));
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
    
} else if (col.getAD_Reference_ID() == DisplayType.YesNo) {
poTmp.set_ValueOfColumn(columnName, new Boolean((value.toString().equalsIgnoreCase("Y")?true:false)));
}else if (col.getAD_Reference_ID() == DisplayType.Number || col.getAD_Reference_ID() == DisplayType.Amount || col.getAD_Reference_ID() == DisplayType.Quantity) {
poTmp.set_ValueOfColumn(columnName, new BigDecimal(value.toString()));
}else if (col.getAD_Reference_ID() == DisplayType.Integer) {
poTmp.set_ValueOfColumn(columnName, new Integer(value.toString()));
}else {
poTmp.set_ValueOfColumn(columnName, value);
}

poTmp.saveEx();

?????



Andrea



Il giorno venerdì 10 febbraio 2017 10:08:45 UTC+1, Hiep Lq ha scritto:
callout is a function, so you can call it anywhere you have reference of callout.
but how about parameter? 
at least on model you can't get reference to gridtab, gridfield, a parameter of callout.
On Fri, Feb 10, 2017 at 3:44 PM, Andrea Checchia <andrew...@gmail.com> wrote:
Goodmorning everyone.

I wanted to know if it was possible to directly call a callout from a class / model java.
I created a table / mask where I enter a start date and amount of the performed work hours; at this point from the WebUI, once inserted the amount of hours in the field "Qty-hours", is called the callout that calculates me the date completion of work: start date + "Qty-hours".

How can it be done? Instead of using the "BeforeSave" - "AfterSave" etc of the model, as I call directly callout?

Thanks in advance.

Andrea

--
You received this message because you are subscribed to the Google Groups "iDempiere" group.
To unsubscribe from this group and stop receiving emails from it, send an email to idempiere+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages