Tuesday, December 02, 2025

When AI Writes PeopleCode... Fact or Fiction?

I just asked Gemini the following question:

"Is there a PeopleCode variable to detect Fluid Mode vs Classic mode?"

Gemini responded with, "Yes!" I thought, "FANTASTIC!"

Here is the code snippet Gemini suggested:

If %Component.IsFluid Then
    /* Logic specific to Fluid Mode */
    MessageBox(0, "", 0, 0, "Running in Fluid Mode");
Else
    /* Logic specific to Classic Mode */
    MessageBox(0, "", 0, 0, "Running in Classic Mode");
End-If;

Wow! That is some fantastic PeopleCode! But AI is known to hallucinate. Before trusting this code, we have to ask: Fact or Fiction?

Let's start with line 1:

If %Component.IsFluid Then
It appears Gemini thinks %Component is an object. What does PeopleBooks say?
%Component returns an uppercase character string containing the name of the current component, as set in the component definition.
To confirm, let's try compiling it in Application Designer. The following is a screenshot of the compilation result:

Verdict: Fiction.

%Component contains a primitive string, not an object. Since a primitive string does not have methods. The IsFluid method would be invalid.

I followed up with Gemini by asking:

"Can you share your reference for %Component?"

Instead of sharing a bibliography of cited sources, Gemini shared what appeared to be very legitimate documentation that describes Gemini's understanding of %Component. I attached a screenshot for your reference:




I circled the last statement, because it was the only part of this listing that was true:

"Gemini can make mistakes, so double-check it"

But I have to ask: Where did Gemini get its information? 🤔 Like a crack reporter, Gemini would not reveal its sources.

The good news is that Gemini is a fast learner! I fed Gemini a few authoritative PeopleBooks, such as a reference to PeopleCode System Variables, and Gemini generated a new response. This version is clever, but does it work?

Local ContentReference &oCRef;
Local boolean &isFluidMode;

/* Get the ContentReference object for the currently running content.
This object holds the metadata for the component's setup.
*/
&oCRef = %Session.GetContentReference();

If (&oCRef <> Null) Then
    /* Check the IsFluid property on the ContentReference object */
    &isFluidMode = &oCRef.IsFluid;
End-If;

If &isFluidMode Then
    /* Execute PeopleCode specific to Fluid UI */
    /* ... */
Else
    /* Execute PeopleCode specific to Classic UI */
    /* ... */
End-If;

What do you think? Fact or Fiction?

Let's start with the first line:

Local ContentReference &oCRef;

Unfortunately, ContentReference is not a built-in PeopleCode data type. What about this line?

&oCRef = %Session.GetContentReference();

Strike 2! GetContentReference is not a documented method of the Session object.

Verdict: Fiction.

But Gemini is on to something! The Fluid Mode attribute is visible in Structure and Content, so with a bit of PortalRegistry PeopleCode and the new %CRef system variable, you could write a lot of PeopleCode to determine if the current component is using Fluid mode.

I wanted to spend a few more minutes helping Gemini find the correct answer, so I fed Gemini several more PeopleBooks entries, hoping it would derive the correct answer. Each time, Gemini gave me a new, seemingly authoritative but entirely fictitious response, inventing new App classes and creating new functions.

After a few iterations, I decided to share the correct answer with Gemini. PeopleCode has a built-in function to determine Classic from Fluid: IsFluidMode. Here is Gemini's reply:


"This built-in function provides the clean separation of logic needed when supporting the same component in both Fluid and Classic modes (emphasis added)..."

Should we tell Gemini that a single component cannot be both Fluid and Classic?

This was a fun exercise. It was like a PeopleCode puzzle: find the hidden AI hallucination, and solve the puzzle.

How about you? Do you have interesting stories about AI and PeopleSoft? If so, please share them in the comments. We love hearing your stories!

Today, there is no substitute for experience and a strong personal understanding of PeopleCode. Want to become a PeopleSoft development expert so you can better determine fact from fiction? Enroll in the JSMpros All-access training pass and start learning!

9 comments:

Larry Roux said...

I think AI is theft so try to avoid it at all costs but I did try asking Claude to create some peoplecode for me and it did write some valid code *structure* but filled in the functions with /* implement the coded solution here */ instead of actually doing something useful.

PeopleCode just isn't as well documented online (ie via GetHub, etc) where AI steals it's training data from as, say, C++ or Java so it just doesn't have enough examples to work from.

It could be useful to evaluate existing code (to an extent) to point out stuff like unused variables or bad structure, but as far as coding goes it just isn't all that useful at this time.

Jim Marion said...

Lack of a sample code base is a really good point.

Curtis Melnick said...

I really don't like to call it artificial intelligence because it doesn't really think or reason. I concur that in its current form(s) it's pretty good at pattern recognition, and linear analysis. My fear is that its use and acceptance is becoming "normalized" or achieving a level of defacto acceptance with little to no critical thinking by the user. "Oh, AI said...."

Charlie said...

I personally like using Perplexity, partly because it sites its sources.

Derek Tomei created an LLM that provides instructions for isolating customizations. I'm wondering if the way around ethical concerns is the use of private models. I don't know enough about how it works to say more about that, but I'm intrigued.

Another thing to perhaps feed it - all the existing PeopleCode! If you do a search for semi-colon (the symbol) in scope PeopleCode and output to a file, you get a text file with all the PeopleCode in it. It include a reference to the object its in, as well.

Perhaps, Jim, you should also try feeding it, say, PeopleTools Tips & Tricks, for some more context!

Jim Marion said...

I like to call it "Algorithmic Intelligence," but maybe the word "Intelligence" is incorrect?

Jim Marion said...

@Charlie, haha! We fed this blog and our GitHub repository to our digital assistant at jsmpros.com. We are also in the process of building AI into our videos and lesson guides for our on-demand site.

Bruce said...

AIs are not all the same. Some can write music, others can make video. Claude.ai appears to be "useful for, or trained on, psoft AI" whatever that means.

Insult it or laugh at AI. My guess is that those who do not pursue AI in their jobs will regret it. I am old enough to remember employees who thought their paper filing system was good enough and that computers were gewgaws. I assume that in the next few years, companies will judge you on your adoption of AI.

My hope is that competent psoft developers will be the best at telling AI how to arrange and build a complex system.

Matt Frigo said...

I've had mixed results using AI for PeopleSoft related items. My experience has been similar to Larry's; it appears that there is not enough information for it to use. I've had a much better hit rate asking about Python.

I've had much better luck using NotebookLM for PeopleSoft stuff. I have two separate notebooks for now; one with FSCM PDF PeopleBooks and one for PeopleTools. I used your question Jim and it returned the UIDisplayMode and IsFluidMode functions with links to the individual pdfs.

Jim Marion said...

I received a great tip on claud.ai for PeopleSoft. It came up with the correct answer on the first try. Actually, it came up with the same response as your NotebookLM reply, highlighting IsFluidMode as the best option.