Accessing Related Fields in PeopleCode

Accessing Related Fields in PeopleCode

In PeopleTools Application Designer Page development, there is a concept of a “Display Control Field” and a “Related Display field.” For example, You have an employee’s department code of 45923 on a page and you want to display the department description on the page along side it. On the page field properties of JOB.DEPTID, you can make the field a “display control field.” You can then place the DEPT_TBL.DESCR field on the page as a related field to the JOB.DEPTID field.

There are times where you need to get access to this related display in code. For example, lets say you are generating an automated email with some of the page detail in the email body and you want to display the Department Description along with the code.

One approach would be to get the JOB.DEPTID from the buffer and then do a SQLEXEC or similar look-up on the DEPT_TBL. This works but is creates another redundant call to the database. The component processor has already looked up the description from the database and it is in memory in the component buffer. Here is how to get access to it in the code.

For this example assume that the JOB record is at level zero in the component.

Here is a “one liner” which is my preference as you need to declare less variables.

LOCAL  string &deptDescr;

&deptDescr = getlevel0()(1).JOB.DEPTID.GetRelated(DEPT_TBL.DESCR).VALUE;

Here is a more verbose version of the same code broken down.

local field &fldDeptid;

&fldDeptid = getlevel0()(1).JOB.DEPTID;

local field &fldRelatedDeptDescr;

&fldRelatedDeptDescr = &fldDeptid.getRelated(DEPT_TBL.DESCR);

local string &deptDescr;
&deptDescr = &fldRelatedDeptDescr.value;

What I really don’t like about this code is that you have to hard code the record field reference in the code. So if someone changes the related display on the page do something like DEPT_EFF_VW instead of DEPT_TBL this code will be broken. Unfortunately, there is no way in the current PeopleCode Field API to “ask” for a list of related fields.

You can pass dynamic references to the getRelated method. For example lets say you looked up the related field from the PeopleTools tables or you had it in a setup table by passing the related record dot field reference as a string prefaced by the @ symbol.

Local String &relatedField;
&relatedField = "DEPT_TBL.DESCR";

LOCAL  string &deptDescr;
&deptDescr = getlevel0()(1).JOB.DEPTID.GetRelated(@&relatedField).VALUE
1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值