web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

In X++ display method

(0) ShareShare
ReportReport
Posted on by 1,215

Hi guys,

i have a scenario in position Form

if it is open position  i want to below option in display method how to do in x++ give us a example. 

1.Position occupied - "Empty"
2.New position - "New"
3.Old position already assigned - "Reuser" .

thanks.

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    300,917 Super User 2025 Season 2 on at

    Hi Riyas,

    Can you explain your definition when an open position is new? Is it date based or e.g. when there are no historical position assignments?

    What exactly do you mean with "Old position already assigned"? If it is assigned, then it is not an open position, right?

  • Riyas ahamed F Profile Picture
    1,215 on at

    thanks for your replay sir,

    yes! i want to display method and just a return all of hardcore value.

  • Pete Alberts Profile Picture
    3,542 on at

    Hi Riyas

    You have stated a requirement, not a problem. Please expand.

    If you are struggling to write and use a display method - just google "x++ display method". And then if you are struggling with the logic in the display method, you'll need to provide some more information. Table and field names please

  • Riyas ahamed F Profile Picture
    1,215 on at

    thanks for your replay pete,

    i want to in the display method if it a new position i need it return "new"

    then if it old position return "reuser" and Position occupied "Empty" so that i wrote a small code

    but still i'm confusing below my code.

    public display Description getPosition()
    {
        HcmPositionRecId _positionRecid;
        HcmPositionWorkerAssignment hcmPositionWorkerAssignment;
        HcmPositionDetail hcmPositionDetail;
        HcmJob hcmJob;
        if(_positionRecid)
        {
           // i was wondering how to here
           
        }
       return "Empty"   "New"   "Reuser";
    }

  • Pete Alberts Profile Picture
    3,542 on at

    So I can't reconcile my knowledge of HR with your requirement. So let's discuss the table structure first (my functional knowledge is not great, so take it with a pinch of salt):

    • There are positions: HcmPosition and HcmPositionDetail. Both are cross company and then HcmPositionDetail is a VTS (valid time state) table
    • Then you have workers: HcmWorker
    • From there you have HcmPositionWorkerAssignment which is a VTS combination of worker & position.

    From the above: 1) It is a long jump to define a position as "New". Maybe the requirement is to determine if a worker has been assigned to the position? 2) "Empty" is straight forward 3) I do not understand "reuser". And I also don't understand what the connection is between an "old position" and "reuser".

    Then from a technical point of view:

    • Your return statement does not make sense
    • The method name does not make sense
    • You need some sort of select statement
    • Underscores are for method parameters (convention, not a rule, but still).

    This method should not be on the form. It should be on the table. Which one exactly I do not know. What form are you extending?

    You'll have to try again with explaining the requirement.

  • Verified answer
    Pete Alberts Profile Picture
    3,542 on at

    So what I think you want is an indication for a position:

    • A worker has never been assigned to the position => "New"
    • A worker has been assigned to the position, but currently it is vacant => "Empty"
    • The position is currently assigned to a worker => "Assigned"

    Then I'd check if there is existing logic to do this. If there is none, then you should create an enumeration for this purpose.

    It should be a display method on HcmPositionDetail in my opinion. Something in this direction:

    [ExtensionOf(tableStr(HcmPositionDetail))]
    final class HcmPositionDetailXYZ_Extension
    {
        [SysClientCacheDataMethod]
        display XYZPositionState positionStateXYZ()
        {
            XYZPositionState positionState;
            
            HcmPositionWorkerAssignment positionWorkerAssignment;
            
            //check if there is a current assignment
            select firstonly RecId from positionWorkerAssignement where
                positionWorkerAssignment.Position == this.Position;
            if (positionWorkerAssignment.RecId)
            {
                positionState = XYZPositionState::Assigned;
            }
            else
            {
                //check if an assignment has ever been made
                select firstonly validtimestate(DateTimeUtil::minValue(),DateTimeUtil::utcNow()) RecId from positionWorkerAssignment where
                    positionWorkerAssignment.Position == this.Position;
                positionState = positionWorkerAssignment.RecId ? XYZPositionState::Empty : XYZPositionState::New;
            }
            
            return positionState;
        }
    }

    I am sure that most of the code I wrote there can be replaced by existing MS methods.

    Good luck

  • Riyas ahamed F Profile Picture
    1,215 on at

    thanks for your valuable answer pete.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 664 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 522 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 303 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans