cancel
Showing results for 
Search instead for 
Did you mean: 

Script:Trouble in auto-populating value of Year object picker with script

Former Member
0 Kudos

Hello,

I am trying to set the value of the M_ERS_YEAR (an object picker of years) field of an extension collection column and field was stored in FCI_MAS_TIMEPERIOD table .

The above Collection field value should auto-populate based on a extension field M_ERS_DATE .

For Ex: If i select 11/01/2011 value for M_ERS_DATE , M_ERS_YEAR collection field should be populated with Year 2011 value .

I tried out by using Set(value) method . but on re-open the Year field appears to be blank .

can any one guide me , how to pull the Year value from time Period table and set to M_ERS_YEAR collection field using Script

Any assistance would be greatly appreciated.

Thanks!

Tayi

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

It's a little more complex than it seems as you have to 'find' the time period first then set the extension collection member field using a reference to that time period:

//the date stored in the extension field is returned as a sysDateIfc

SysDateIfc someDate = doc.getExtensionField("M_ERS_DATE").get();

//get a home Bean for the time period type

ValueListValueIBeanHomeIfc vlvHome = IBeanHomeLocator.lookup(session, ValueListValueIBeanHomeIfc.sHOME_NAME);

//get a bean for the year VLV

ValueListValueIBeanIfc timePeriodYearType = vlvHome.findUniqueByNameType("Year",ValueListTypeCodeIfc.nTYPE_TIME_PERIOD_TYPE);

//get the home Bean for the Time Period

TimePeriodIBeanHomeIfc timePeriodHome = IBeanHomeLocator.lookup(session, TimePeriodIBeanHomeIfc.sHOME_NAME);

//find the time period for the year in question

TimePeriodIBeanIfc timePeriod = timePeriodHome.findByDateAndType(someDate,timePeriodYearType.getLocalizedObjectReference());

//don't know what your collection name is but you have to retreive the collection then iterate through it to find the right member

extCollMember.set("M_ERS_YEAR",timePeriod.getObjectReference());

Hope this helps

Alan

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Alan ,

I have imported the Time bean . I hope It's not 5.1 version . any chance to check the version from Front end

RG holds only TimePeriodSubIBeanIfc interface alone ..

Thanks,

Tayi

Former Member
0 Kudos

Hi Alan ,

I have imported the Time bean . I hope It's not 5.1 version . any chance to check the version from Front end

RG holds only TimePeriodSubIBeanIfc interface alone ..

Thanks,

Deepika T

Former Member
0 Kudos

Hi Alan ,

Imported the Time Bean Interface . E-sourcing version is 3.2 . Referenc Guide contains TimeperiodSubIBeanIFC . Trying to access this interface also showing error as "Not found in Name space "

Any suggestion,

Thanks,

Tayi

Edited by: TDeepika on Jan 19, 2011 12:03 PM

0 Kudos

Tayi,

Sounds like you have a very old version of Frictionless SRM. I was not aware scripting was available in that version.

My best suggestion would be an upgrade.

Alan

Former Member
0 Kudos

Problem Resolved

Former Member
0 Kudos

Hi Alan ,

Thank you . when i'm trying to use TimePeriodIBeanHomeIfc Interface . System throws error of TimePeriodIBeanHomeIfc not found in Name Space .

In Reference Guide I'm not able to view the TimePeriodIBeanHomeIfc Interface .. Only TimePeriodSubIBeanIfc interface is available and it has not hold sHOME_NAME ..

Please guide me

thanks,

Tayi

0 Kudos

Tayi,

What version are you using? In my 5.1 version of the Integration API, I can see both TimePeriodIBeanIfc and TimePeriodIBeanHomeIfc.

Did you place an import statement at the top of your script for these?

import com.frictionless.api.doccommon.masterdata.*;

You'll probably need to add import statements for other classes referenced in the code I posted. The full names can be found in the JAVA IAPI index from the RG.

Alan