Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Answered

How I will identified, which user submitting the workflow?

Posted on by 5,885

Hi All,

How I will identified, which user submitting the workflow?

I passed as a parameter curUserId (). As workflow is running in batch. Shall I identified the user ,who submitting the workflow ?

Please give me more shed on this 

  • @rp@n Profile Picture
    @rp@n 5,885 on at
    RE: How I will identified, which user submitting the workflow?

    thanks Ergun

  • Verified answer
    ergun sahin Profile Picture
    ergun sahin 8,812 Super User on at
    RE: How I will identified, which user submitting the workflow?

    AD(Active Directory) account is not an ax related issue.

    I'm sharing the link below to give you an idea, but it will show changes based on the environment you use,

    docs.microsoft.com/.../ee617240(v=technet.10)

    Very high probability of you are not authorized And there is probably already such an account (usually opened during ax installation).

    In its simplest form, you can have information by examining which user opened other batches. (Or ask for help from system experts working in your company)

    There is no such thing as assigning the service account to the batch. You need to connect to ax with the relevant service account and set up the batch as you would with your own user.(Of course you must have created a user in ax for account)

  • @rp@n Profile Picture
    @rp@n 5,885 on at
    RE: How I will identified, which user submitting the workflow?

    Thanks Ergun,

    What I understand,  the Active directory service account with never expired password is best option for repitative batch job in AX.

    Which having less chance to fail.

    Am I right ?

    Kindly let me know,  how will create AD service account ? Where assign that service  account in batch?

    Please give me more shed on this 

  • Verified answer
    ergun sahin Profile Picture
    ergun sahin 8,812 Super User on at
    RE: How I will identified, which user submitting the workflow?

    The problem is that you set up the batch with your own user. When the batch is set up with normal users, if the user is closed for any reason, the batches will also give an error.

    Also, as you are experiencing right now, when you set up a batch with your own user, you cannot tell whether the records were created manually or by batch.  So use a different user(a service user or admin)

    "Repeating batches must not be under a regular AD account, but as a service account. Create an Active Directory service account, with a password which does not expire. Provide the necessary AX user credentials, allow log on as a service, then set up all your recurring batch jobs under that credential"

    community.dynamics.com/.../batch-jobs-running-as-user

  • @rp@n Profile Picture
    @rp@n 5,885 on at
    RE: How I will identified, which user submitting the workflow?

    Thanks Ergun,

    I have also used before curUserId as parameter. But I couldn't proof, is it batch user I'd ir normal user I'd. It is talking my user I'd as curUserId.

    As you said

    "also possible to use a batchUserId(curUserId) or a UserId to be defined in the parameters, (with this logic you can known the workflows was created by batchjob.)"

    *** How can I justified,  the userid is batch userid or not?

    Becuse as per business logic , I need to pass parameter batch user I'd only while submitting the WF.

    Please give me more shed on this

  • Suggested answer
    ergun sahin Profile Picture
    ergun sahin 8,812 Super User on at
    RE: How I will identified, which user submitting the workflow?

    Yes, but as I said before, it's about the process, you have to decide which user should start the workflow.

    I think it is most logical to use the user who created(createdby) this table record.

    If you use the worker field there is possibilty changing user later but you can't change createdby field (of course for records that are not sent to the workflow)

    If the records you want to send to worflow are created by batch, one of these two fields will be empty(or batchUserWorker) and the other will be batch user Id. In this case, it is necessary to look at alternative fields.

    You don't have to use either of these two fields. There are similar fields on Vendor or item.

    It is also possible to use a batchUserId(curUserId) or a UserId to be defined in the parameters, (with this logic you can known the workflows was created by batchjob.)

  • @rp@n Profile Picture
    @rp@n 5,885 on at
    RE: How I will identified, which user submitting the workflow?

    Thanks Ergun

    1.operation with batch to submit workflow,  these 2 fields -

    purchTable.CreatedBy or purchTable.WorkerPurchPlacer  

    Only we can use? To capture who submitting the workflow ?

    2. But before using any fields, we need to check business requirements which fields get fit as per our requirements.

    Am I correct?

    Please give me more shed on this

    Thanks !

  • Suggested answer
    ergun sahin Profile Picture
    ergun sahin 8,812 Super User on at
    RE: How I will identified, which user submitting the workflow?

    There are many cases where this field is empty or not associated with the employee you want (such as CurUserId not associated with a user, creating records with batches or creating records with custom codes etc.)

    Before you decide to use this field, it is useful to examine the records in the table and check whether it contains the information you want.

  • @rp@n Profile Picture
    @rp@n 5,885 on at
    RE: How I will identified, which user submitting the workflow?

    Thanks Ergun

    As you said,"You can use purchTable.CreatedBy or purchTable.WorkerPurchPlacer (if its full)"

    What do you mean

    WorkerPurchPlacer (if its full)" ? Kindly elaborate please 

    Please give me more shed on this 

    Thanks!

  • Verified answer
    ergun sahin Profile Picture
    ergun sahin 8,812 Super User on at
    RE: How I will identified, which user submitting the workflow?

    First you need to determine which user to use. This is a process issue, you have to make the decision, but if you ask my opinion;

    You can use purchTable.CreatedBy or purchTable.WorkerPurchPlacer (if its full).

    CreatedBy holds the userId, so you can use it in the code. For the Worker field, you can get userId;

    userId = HCMWorker::findPersonUser(purchTable.WorkerPurchPlacer).User;

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,989 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,588 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans