Monday, April 27, 2009

Viewing PeopleCode Online

Is is possible to see PeopleCode asscociated with any Record Field/Component/Page etc, online( Through PIA) ?

Yes, thanks to %matadata API.

Use following code at behind a push button (Field Change) and you'll see the code as a message pop up. ( Please enter record, field and event name in below code.)


import %metadata:PeopleCodeProgram:PeopleCodeProgram;
import %metadata:PeopleCodeProgram:PeopleCodeProgram_Manager;
import %metadata:Key;

Local %metadata:PeopleCodeProgram:PeopleCodeProgram_Manager &mgr = create %metadata:PeopleCodeProgram:PeopleCodeProgram_Manager();
Local %metadata:Key &key = create %metadata:Key(Key:Class_Record, , Key:Class_Field, , Key:Class_Method, ;
Local %metadata:PeopleCodeProgram:PeopleCodeProgram &Prog = &mgr.GetDefn(&key);

If &Prog <> Null then

Local string &sProgramText = &Prog.GetProgram();
winmessage(&sProgramText ,0);

else

Winmessage("No PeopleCode Event Defined",0);

end-if;

3 comments:

  1. Hi,

    After placing record, field and peoplecode in above code, it is giving syntax error.

    Local %metadata:Key &key = create %metadata:Key(key:Class_Record, Record.OMS_RECORD_WRK, Key:Class_Field, Field.BUTTON, Key:Class_Method, Method.FieldChange);

    I have placed only one line which i have modified.

    Please help...

    Also could you please give me more information about %metadata (where I can see the code).

    Thanks
    Madhusudhan.

    ReplyDelete
  2. Hi,
    Below is the way..

    Local %metadata:Key &key = create %metadata:Key(key:Class_Record, "OMS_RECORD_WRK", Key:Class_Field, "BUTTON", Key:Class_Method, "FieldChange");

    ReplyDelete
    Replies
    1. Hi,

      Can you please guide us how to create record definiition using %metadata.

      Delete