In this article, we will see step by step procedure to attach a file and store it in the database....
A function is a named section of a program that performs a specific task that can be reused. The main advantages of functions are resusability and ease of maintainance.
Listed below are types of Peoplesoft functions
Declaring a function using PeopleCode is pretty straight forward and this is how you can do that:
Declare Function delete_attachment PeopleCode FILE_ATTACH_WRK.ATTACHDELETE FieldFormula;
delete_attachment is the function name you want to declare. FILE_ATTACH_WRK is the record where the function has been stored, and ATTACHDELETE is the field the function is under, and finally FieldFormula is where the function is located within the “ATTACHDELETE” field.
These are peoplesoft delivered functions. These functions do not required declaration, We can directly use the functions.
Hide(<RECORD.fieldname>); SQLEXEC(<sql string>);
We call these function at the same place or program we define. For example, we can write a function in RowInit of a field and call it in same event. Declaration is not Required. Given below is an example
RECORD1.FIELD1 = add_preceding_zeros("my_value"); RECORD1.FIELD2 = add_preceding_zeros("my_value"); Rem this function returns a 10 character string with preceeding zeros,if len of the variable passed is less than 10 Function add_preceding_zeros(&STR_ID) Returns string Return Substring("0000000000", 1, 10 - Len(&STR_ID)) | &STR_ID; End-Function;
There functions are defined under other records/fields or libraries. Declaration is required for this type of functions. Some records that come with people soft installation come with some of this functions, For Example, FILE_ATTACH_WRK record has function in its FieldChange that is generally used in file attachments.
Using the add_attachment function under FILE_ATTACH_WRK.ATTACHADD FieldChange event is given Below. The Below code should be used on your record and not on FILE_ATTACH_WRK. In this case the code is written in ComponentRecord FieldChange Event of my record
Declare Function add_attachment PeopleCode FILE_ATTACH_WRK.ATTACHADD FieldChange; &uniquefilename = %OperatorId | "_" | String(Month(%Date)) | "_" | String(Day(%Date)) | "_" | String(Year(%Date)) | "_" | String(Hour(%Time)) | "_" | String(Minute(%Time)) | "_" | String(Second(%Time)); &ATTACHSYSFILENAME = &uniquefilename; &RECNAME = "Record." | Record.DLYATTCH;rem YOUR RECORD NAME HERE add_attachment(URL.GL_FILE_IMPORT, "", "", 0, False, &RECNAME, &ATTACHSYSFILENAME, &ATTACHUSERFILE, 2, &Return_Code);
These functions are defined under the external third party systems libraries. Declaration is required for this functions.