Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Script component set get / ProcessDataValue

Avatar

Former Community Member
Inside the script cmponent how can I set and get the process data

which is either Object or custom Object?



I found some info at on these methods

patExecContext.setProcessDataValue(aPath, aVal)(aPath, aVal)patExecContext.getProcessDataValue(aPath)

at http://kb.adobe.com/selfservice/viewContent.do?externalId=kb402587

but it is not working as mentioned but getting error (see below) any clue why?



Thanks

Yog



Target exception: ALC-DSC-119-000: com.adobe.idp.dsc.util.InvalidCoercionException: Cannot coerce object:
5 Replies

Avatar

Level 10
What variable type are you trying to set?



For example if you want to set a string you can use setProcessDataStringValue(path,value) although setProcessDataValue() should work.



Jasmin

Avatar

Former Community Member
It is the custom veriable type. ( A custom component exports this custom data type note: I can see this variable type while creating new variable so it is visible to LCWB)



Thanks

Yog

Avatar

Former Community Member
// I able to overcome InvalidCoercionException error it was classpath problem but still not able to get it work getting null pointer



// ok here is simple test script TestExport is just plain POJO



import TestExport;

TestExport testExport = new TestExport();

System.out.println(" TESTING NOW 1");

testExport.setName("YYYYYYY");

System.out.println(" TESTING NOW 2");

testExport.setId("IDDDDD");

System.out.println(" TESTING NOW 3");

patExecContext.setProcessDataValue("/process_data/testExport", testExport);



System.out.println(" TESTING NOW 4");



TestExport testExport2 = (TestExport) patExecContext.getProcessDataValue("/process_data/@testExport");



testExport = (TestExport) patExecContext.getProcessDataValue("/process_data/@testExport");



System.out.println(" TESTING NOW 5"); // till here get printed

System.out.println(" testExport2 is here = "+ testExport.getNameID() );// throw null pointer



System.out.println(" testExport2 is here = "+ testExport2.getNameID() );// throw null pointer

System.out.println(" TESTING NOW 6"); does not print this

Avatar

Level 10
What is the type of /process_data/testExport in Workbench? Did you create a custom data type called testExport? Or you used Object?



Jasmin

Avatar

Former Community Member
Hi Jasmin,
The type of /process_data/testExport in Workbench is TestExport, I created a custom data type called TestExport inside package mycommonpackage.
The component that export this datatype has component.xml with export as below.


mycommonpackage


---------
Another related question: when does the custom component start showing up inthe xpath builder under property tab?
Thanks
Yog