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, ...
Unanswered

Select statement for table PSAProjSchedRole is working in test but not working in Live.

(0) ShareShare
ReportReport
Posted on by 518

Hi all,

In the below code, even the data is in the table projSchedRole.ProjId matches with the data in the projTable.ProjId and projSchedRole.Worker == _worker

projSchedRole is not selecting any record.

Its working on test env. but not working in live. 

Can you anyone help and tell why its not working in live env.

PSAProjSchedRole projSchedRole;

if(event == "RoleStart" || event == "RoleEnd")
    {
        select * from projSchedRole where projSchedRole.ProjId == projTable.ProjId
                                        && projSchedRole.Worker == _worker;
            if(projSchedRole)
            {
                if(projSchedRole && (event == "RoleStart" || event == "RoleEnd"))
                {
                    resourceName = HcmWorker::find(projSchedRole.Worker).name();
                }
            }
    }

Thanks and regards

Siddhant Singh

I have the same question (0)
  • Martin Dráb Profile Picture
    237,908 Most Valuable Professional on at

    First of all, let me format your code and remove duplicate code, so it's easier to read:

    if (event == "RoleStart" || event == "RoleEnd")
    {
    	PSAProjSchedRole projSchedRole;
    
    	select projSchedRole
    		where projSchedRole.ProjId == projTable.ProjId
    		   && projSchedRole.Worker == _worker;
    		   
    	if (projSchedRole)
    	{
    		resourceName = HcmWorker::find(projSchedRole.Worker).name();
    	}
    }

    Unfortunately there isn't much we can tell you, because it all depends on what data you have in the database (for the current company) and values of projTable.ProjId, event and _worker variables.

  • Blue Wang Profile Picture
    on at

    HI Siddhant Singh,

    Is the data of Test and Live environment exactly the same?

    You can write a select statement in SSMS to compare whether there is data that meets the conditions in the Live environment

  • Siddhant Singh Profile Picture
    518 on at

    Hi Blue Wang,

    I tried the query in Live SSMS and got the output with this select query but when i am trying this on AX its not returning any value.

    And also my event is coming correct and variable _worker is having right value.

    Can you tell what may be the reason behind it.

    Thanks and regrads

    Siddhant Singh

  • Martin Dráb Profile Picture
    237,908 Most Valuable Professional on at

    Can you show us your T-SQL code, please? People often forget to include DataAreaId in relations in T-SQL and then the result may be completely misleading.

    Do you execute both T-SQL and X++ in the company context?

    You said that you're sure that two of the three variables have the right value. What about the project ID?

  • Siddhant Singh Profile Picture
    518 on at

    Hi Martin,

    Yes I executed both SQL and X code in company context.

    Project Id is also matching in sql. In SQL code with and without dataAreaId the output is same only. 

    select * from PSAPROJSCHEDROLE
     where PSAPROJSCHEDROLE.ProjId = 'ABC-0000**'
       and PSAPROJSCHEDROLE.Worker = 5637******
       and PSAPROJSCHEDROLE.DATAAREAID='ABC'

    pastedimage1596021435494v1.png

    Do by running full CIL will help in this case to remove this defect.

    Thanks and Regards

    Siddhant Singh

  • Martin Dráb Profile Picture
    237,908 Most Valuable Professional on at

    I can think of two explanations:

    1. One or more values are not what you expect (DataAreaId, ProjId, Worker, event).
    2. Or the data in database isn't the same when executing your code (because there are uncommitted changes done in the same transaction).

    (For completeness: I'm not taking Partition into account here, because I assume it's not the current problem.)

    If you believe that everything is correct, then I suggest you get Live data to a development environment and debug code against Live data.

    Compiling the Live environment shouldn't be necessary - that should have been be done when deploying code to Live. If you get into situation when it's needed, then your deployment process doesn't work correctly.

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 544 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans