Skip to content

Instantly share code, notes, and snippets.

@nvg
nvg / ps_save_rec.ps
Created August 28, 2020 18:47
PeopleCode to save a record
Declare Function SetConfirmationMessage PeopleCode PT_WORK.PT_CONFIRM_MSG FieldFormula;
/* note that &p_rec.Save() won't work in all cases - it does SELECT FOR UPDATE in the background and may fail silently */
If Not &p_rec.Update() Then
If Not &p_rec.Insert() Then
SetConfirmationMessage("Unable to save");
Return;
End-If;
End-If;
SetConfirmationMessage("Saved successfully");
@nvg
nvg / ps_init_rs.ps
Created July 5, 2019 17:55
PS: Init Rowset
/* Clear SOME_RECORD scroll */
Local RowSet &rs = GetLevel0()(1).GetRowset(Scroll.SOME_RECORD);
&rs.Flush();
Local number &i;
Local number &rowCount = 1;
/* Insert 10 dummy records */
For &i = 1 To 10
Local Record &r = CreateRecord(Record.SOME_WORK_RECORD);
@nvg
nvg / PHIRE_migrations.sql
Created December 13, 2018 21:15
Query to pull PHIREs with changes include records and fields
SELECT A.PHI_DOMAIN_ID, A.PHI_CR_NUM, A.PHIOBJTYPE, A.PHIOBJID1, A.PHIOBJVALUE1, TO_CHAR(CAST((B.PHI_MIGR_DTTM) AS TIMESTAMP),'YYYY-MM-DD-HH24.MI.SS.FF'), B.PHI_SOURCE_DB, B.PHI_TARGET_DB
FROM PS_PHI_CR_OBJECT A, PS_PHI_CR_MIGR_REQ B
WHERE ( A.PHI_DOMAIN_ID = B.PHI_DOMAIN_ID
AND A.PHI_CR_NUM = B.PHI_CR_NUM
AND A.PHIOBJTYPE IN ('RECORD','FIELD')
AND B.PHI_MIGR_DTTM BETWEEN TO_DATE(:1,'YYYY-MM-DD') AND TO_DATE(:2,'YYYY-MM-DD') )
@nvg
nvg / ps_get_rec.ps
Last active July 5, 2019 17:48
PS: Get record
method GetRec
/+ &p_key as String, +/
/+ Returns Record +/
Local Record &result = CreateRecord(Record.MY_REC);
Local string &sqlStr = "SELECT * FROM PS_MY_REC WHERE KEY = :1";
SQLExec(&sqlStr, &p_key, &result);
Return &result;
/* - OR - */
@nvg
nvg / psunit_base.ppc
Last active February 24, 2022 03:31
peoplecode: PSUnit base
import TTS_UNITTEST:TestBase;
class Test extends TTS_UNITTEST:TestBase
method Test();
method Run();
method Setup();
protected
private
instance string &someValue;
@nvg
nvg / rec_to_str.pc
Last active July 20, 2017 15:01
peoplecode: record to string
Local number &z;
Local string &s = "";
For &z = 1 To &rec.FieldCount
&s = &s | " " | &rec.GetField(&z).Name;
try
&s = &s | "=" | &rec.GetField(&z).Value;
catch Exception &err
&s = &s | "=" | "[f%#k]";
end-try;
End-For;
@nvg
nvg / FieldSorter
Created July 4, 2017 14:30
peoplecode: field sort order
/**
Ensures that dropdown field ordering is maintained, overriding the default alpha order
in PeopleSoft.
*/
class FieldSorter
/**
Reloads XLATS for the specified and and sets them in the load order
*/
method sortXlats(&field As Field);
end-class;
@nvg
nvg / declare.pc
Created June 30, 2017 18:48
peoplecode: Declare (Import) Function
Declare Function FunctionName PeopleCode RECORD.FIELD FieldChange;
@nvg
nvg / clean_non_printables.pc
Created June 21, 2017 19:30
peoplecode: clean non-printable characters
/**
Utility to clean record from non-printable characters
*/
class RecordClean
/**
Cleans all text fields in the specified record from non-printable characters
*/
method cleanRecord(&p_rec As Record);
/**
@nvg
nvg / component_search.sql
Created June 19, 2017 17:58
peoplecode: sql: component search
---- Menu Look-up
SELECT SRCH.PORTAL_LABEL LABEL
, NVL(SRCH.PORTAL_URI_SEG2, ' ') COMPNOENT
, SRCH.PORTAL_OBJNAME
--L1.PORTAL_LABEL, L2.PORTAL_LABEL, L3.PORTAL_LABEL,
--L4.PORTAL_LABEL, L5.PORTAL_LABEL, L6.PORTAL_LABEL
,'Main Menu > ' || L1.PORTAL_LABEL || decode(L1.PORTAL_REFTYPE, 'F', ' > ')
|| L2.PORTAL_LABEL || DECODE(L2.PORTAL_REFTYPE, 'F', ' > ')
|| L3.PORTAL_LABEL || DECODE(L3.PORTAL_REFTYPE, 'F', ' > ')
|| L4.PORTAL_LABEL || DECODE(L4.PORTAL_REFTYPE, 'F', ' > ')