Pass a parameter to a CRM 2011 Workflow via the API - workflow

I have a workflow that has a 'Prompt and Response' dialogue. I can run the workflow from the API using ExecuteWorkflowRequest but how do I provide values for the prompt and response inputs?

Workflows don't take parameters.
Dialogs take parameters, which are generally passed from other dialogs or queries.
The only thing I managed to do is to pass a related entity from parent workflow as the primary entity to a child workflow.

I'm going to retract my earlier answer and upvote #Grigory instead.
See this page from the SDK
Note Due to the interactive nature of the dialog process, you cannot run a dialog using the Microsoft Dynamics CRM SDK. A dialog can
only be run through the Microsoft Dynamics CRM Web application and are
not supported in Microsoft Dynamics CRM for Microsoft Office Outlook
with Offline Access.
I don't know the answer, but I'd be fairly confident that this is:
Possible
Unsupported (as it is not documented in the SDK)
If I really needed to find out then I'd write a plugin to explore what happens when a workflow is fired internally (this makes an assumption that such a message is fired via the plugin pipeline - not necessarily a correct assumption).
I'd register this plugin on all stages of the Execute message (I assume) and then use debug logging or an interactive debug session (attached to the Async service) to examine the InputParameters (and maybe OutputParameters and ExtensionData) of the ExecuteWorkflowRequest that is (hopefully) generated when CRM runs a workflow that does have parameters. I expect that one of those PropertyBags will contain some sort of parameter.

Related

Fetch all metadata of Salesforce

I've been trying to implement a way to download all the changes made by a particular user in salesforce using PowerShell script & create a package The changes could be anything whether it can be added or modified, Apex classes, profiles, Account, etc based on the modified by the user, component ID, timestamp, etc. below is the URL that exposes the API. The URL Does not explain any way to do this by using a script.
https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_listmetadata.htm
Does anyone know how I can implement this?
Regards,
Kramer
Salesforce orgs other than scratch orgs do not currently provide source tracking, which makes it possible to pinpoint user changes in metadata and extract only those changes. This is done by an SFDX/Metadata API client, like Salesforce DX or CumulusCI (disclaimer: I'm on the CumulusCI team).
I would not try to implement a Metadata API client in PowerShell; instead, harness one of the existing tools to do so.
Salesforce orgs other than scratch orgs don't provide source tracking at present. To identify user changes, you can either
Attempt to extract all metadata and diff it against your version control, which is considerably harder than it sounds and is implemented by a variety of commercial DevOps tools for Salesforce (GearSet, Copado, etc).
Have the user manually add components to a Change Set or Unmanaged Package, and use a Metadata API client as above to retrieve the contents of that package. (Little-known fact, a Change Set can be retrieved as a package!)
To emphasize: DevOps on Salesforce does not work like other platforms. Working on the Metadata API requires a fair amount of time investment and specialization. Harness the existing work of the Salesforce community where you can, but be aware that the task you are laying out may be rather more involved than you think and it's not necessarily something you can just throw together from off-the-shelf components.

CRM Online - Create email server profile using Powershell

I need to configure email settings for a number of CRM online instances. I want to automate this as some of the sandbox environments will be reset periodically.
I have one instance configured manually (with our on prem exchange) so know what need to be done to get it working but I can't for the life of me seem to be able to retrieve and update the email server profile configuration. I either want to amend the default profile or create a new one.
I'm using the Microsoft.Xrm.Data.Powershell module so i'm able to retrieve entities and records but can't seem to find the specific data i'm after.
Has anybody done this before or able to point me in the right direction?
While I have never done this myself here are some ideas that might help:
The EmailServerProfile entity supports the typical CRUD messages, as well as specialized messages like GrantAccess, ModifyAccess, and RevokeAccess.
Options to run these from PowerShell would include:
Use PowerShell to make requests to the D365 WebAPI, which will require OAuth2
Install the Microsoft SDK Nuget Package(s) into PowerShell, load the appropriate assemblies, then create the .NET objects and run their methods. This post has more info on this type of approach.
This package says it allows you to "invoke any available CRM request", so that might be worth looking into.
I checked this package, which has a lot of commands, including Approve-CrmEmailAddress and Revoke-CrmEmailAddress but did not see anything pertaining to EmailServerProfile.
Here is an example of how I create a fully working hybrid profile in on premise Dynamics installation:
New-CrmRecord -EntityLogicalName emailserverprofile -Fields #{
name = "EmailProfile01"
servertype = [Microsoft.Xrm.Sdk.OptionSetValue]::new("3")
ownerid = $ownerIdReference
exchangeonlinetenantid = $CRMContextId.Guid
useautodiscover = $true
incomingcredentialretrieval = [Microsoft.Xrm.Sdk.OptionSetValue]::new("2")
}

Logging into Outlook using powershell with no user logged on

I was wondering if its possible to create a powershell script to log into a specific outlook mail box and than add the script to the scheduled task so that no user has to be logged on.
If you need to open an arbitrary Exchange mailbox, you can either
Use Outlook Object Model (which cannot be used in a service, such as the Scheduler) to log to a predefined profile (Namespace.Logon) and call Namespace.GetSharedDefaultFolder. If the set of mailboxes is always the same, you can add these static mailboxes to the profile (open them as delegate mailboxes) and access them programmatically using the Namespace.Stores collection. Again, Outlook should not be used in a service/scheduler.
Exchange Web Services - it is HTTP based, so you can use it from a service
Graph - just like EWS, it is HTTP based, so you can use it from a service
Extended MAPI (C++ or Delphi only). native API used by Outlook itself. It can be used in a service.
Redemption (I am its author - it wraps Extended MAPI and can be used in any language from a service). It lets you dynamically log to an Exchange mailbox using RDOSession.LogonExchangeMailbox / LogonExchangeHostedMailbox (no existing profile required). Other mailboxes can be opened using RDOSession.GetSharedMailbox.
Yes, you can log on to a specific user profile programmatically. The Logon method of the Namespace class logs the user on to MAPI, obtaining a MAPI session.
Be aware, Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.
If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution. You can read more about that in the Considerations for server-side Automation of Office article.
Instead, you may consider using a low level API on which Outlook is built - Extended MAPI. Or use any third-party wrappers around that API.

How to send something from Dynamics CRM

I would like to develop a way for sending text messages (SMS) from Microsoft Dynamics CRM 4.0.
For example: clicking a button will open a window where I can enter my message. Clicking send will send a request to the SOAP XML Web Service I'm working with containing the contact's cell number and my text. I also want to be able to install it on some of my customers' CRM servers.
What would be the best way to do this? Should I develop a plug-in or use JScript and integrate it to the workflow?
Thanks!
I'll assume you want to store the message in CRM. You can create a text message custom entity or modify one of the activity entities to store that data.
From there it depends on what you are most comfortable with. You can call web services from either javascript or a custom workflow. A custom workflow tends to allow for better testability and debugging, but is more work to set up and install (not hard, just more work). However, using javascript to communicate with web services can be tedious without some kind of framework (JQuery, Prototype).
My opinion: use a custom workflow.
One of the best ways to do this would be to use Microsoft Biztalk Server

MS WF state machine workflows and MS CRM Dynamics 4.0

MS CRM Dynamics 4.0 incorporates the MS WF engine. The built in designer allows the creation of sequential workflows whos activities have native access to CRM entities.
Is it possible to:
Create a state machine workflow
outside of CRM (i.e. in visual studio) and import it into CRM?
Have this workflow access the CRM
entities?
It is NOT possible to create a state machine workflow for use in MSCRM.
It is also not supported to create any workflow outside of MSCRM and import it.
As a work around you could write either all the logic you need into a custom workflow activity and import that into MSCRM and have it called from a normal workflow.
The other option is build a seperate application which runs a state machine workflow and interacts with MSCRM via the web services. You could (would need to?) combine this with a custom workflow activity to kick off processes.
It is possible to create no code workflow...
http://blogs.msdn.com/jonasd/archive/2008/01/21/Creating-a-no_2D00_code-workflow-for-CRM-4.0-with-Visual-Studio-2005-_2800_2008_2900_.aspx
and take a look at the other thread...
Is is possible/a good idea to edit workflows in Visual Studio?
I don't know the answer to your specific question, but hopefully this information will point you in the right direction.
The "native" format for WF workflows is ".xoml" files. These are basically identical to XAML files, and both are nothing more than generic persistence formats for a .NET object tree. If you can access the saved data that is output by the Dynamics designer, it should be in the same format. If it is, you should be able to open it from the Visual Studio designer.
The key here is that CRM undoubtedly defines its own set of custom activities that you'll need to be able to reference from within the alternate designer. With any luck, these will be in assemblies with obvious names and/or in the GAC.