You are on page 1of 13

PeopleCode Functions

Presenter
Usha Ramesh
User Defined Functions
• Internal to the same Peoplecode program
• Defined by Function
• Call it by using the Function name
• External to the current Peoplecode
program
• Define the function in any Record/Field field
Formula
• Declare and then Call
• External but non Peoplecode function
• Declare with Library
How to write a function?
• Use a Derived Work Record Field
• Write the function in the
FieldFormula Event
• Function <name> (input parameters)
…PeopleCode Statements…
end-function;
How to Call a function?
• Declare the function using the
following syntax.
• Declare function <function name>
peoplecode <recordname.fieldname>
fieldformula;
• Call the function by using the function
name with the necessary parameters
• UpdateLeaveDts(&startdate, &enddate)
How to write a function which
return values?
• Use a Derived Work Record Field
• Write the function in the
FieldFormula Event
• function <name> (input parameters)
returns <datatype>
…PeopleCode Statements…
Return <expression>;
end-function;
• Type can be –
Number/Boolean/string/date/time/dateti
me/any
How to Call a function which
returns values?
• Declare the function using the
following syntax.
• Declare function <function name>
peoplecode <recordname.fieldname>
fieldformula;
• Call the function by using the function
name with the necessary parameters
• Localvariable/recordname.fieldname.value =
CheckforHolidays(&startdate, &enddate);
How to Call a function which
returns values?
• Declare the function using the
following syntax.
• Declare function <function name>
peoplecode <recordname.fieldname>
fieldformula;
• Call the function by using the function
name with the necessary parameters
• Localvariable/recordname.fieldname.value =
CheckforHolidays(&startdate, &enddate)
Built – in Functions
• Message Catelog Functions
• Error/Warnings – MsgGetText(Message Set
Number, Message Number, “defualt text”
• Gray/UnGray(Record.Fieldname)
• Hide/UnHide(Record.Fieldname)
• SetDefualt(Record.Fieldname)
• All(Record.Fieldname, Record.Fieldname)
• None(Record.Fieldname,
Record.Fieldname)
Built – in Functions
• Subtring
• RTrim
• LTrim
• PriorValue
• OriginalValue
• SetCursorPosition
• AddToDate
• String()
• Value()
Reserved Words
• Page.PageName
• Record.RecordName
• Component.ComponentName and so
on..
Object Based Properties
• &field.isChanged
• &Record.isChanged
• &Row.IsNew
• &Row.IsDeleted
Assignment
• Design a component to add a new
school code and its description.
Define its type as
Academic/Training.School Code
should be autoincremented.
Description is mandatory. Store the
first 10 characters to short
description if it is empty.
Question???

You might also like