SSIS - Batch execution in script task - ssis

I need to run a particular action in Dynamics 365 for every record that gets created in a entity. i'm able to do it via script component(in C#).
The problem is script component opens CRM connection, executes a action and closes the connection for every record from my input. Input to script component is a single column(result from fetchXML) containing the GUID's of record on which i need to run the action.
The way i'm doing now is to add the GUID of record in Input0_ProcessInputRow() method to a list and execute the respective action in a batch of 10 records in PostExecute().
I understand PostExecute() is usually used for cleanup things.
I'm looking for a better/clean way to do this?

Related

SSIS event handler script task

i have a package that has several event handlers that execute a script task on failure when the package fails.. Problem is its generating a email that i have NO IDEA how.. When the package fails it executes a stored procedure that grabs the email distribution list from a SQL table and sends an email. However one email is being sent out to ppl who are not with the company and ive been told twice to change the DL list.. I checked the SQL table and the people that are getting the email are not listed any where in the distribution list.. Is there any way to search anywhere in the package to find out how the email is being generated. Ive spent hours and hours going through the scrip tasks and the code is no where to be found
You can use the package explorer (to the right of the event handler tab) to navigate through the entire package and look at the event handlers for every executable. It's possible that there are multiple event handlers, one at the package level and maybe one defined on a particular task, which is hardcoded with email addresses.
You can also, right click on the package in the solution explorer and select View Code. This will open the package in xml, which you can then use ctrl+F to find a certain string.
Advice Section
While you didn't ask for it, please let me add a few words of guidance. Event handlers are evil for this very reason. They are a hidden GOTO that you are lucky to notice at all, even if you've developed the package in the first place.
If event handling is required, use the precedence constraints in the control flow. Throw everything in a container, connect it to the script task and define the constraint to trigger on failure.
To go one step further, keep your emails out of your ssis packages. Use SQL agent or whatever scheduler you are using to post messages about failures.

SSIS- SQL AGENT Sending Mail for Each hour

i have designed a SSIS Package which will load some data to table
from the file available in a folder.
once data got loaded file move to archieve.
Client requested to have mail trigger at the end of process, so i implement
it through send mail task.
The pooling mechanism was done via agent job which run after evry 1 hour
to check existence of file.
The problem starts here.
it start sending mail every 1 hr to user
will it be possible to do some modification.
Thanks You All...... i think my question was not clear. The Problem i am facing is my package is start trigger mail every 1 hour, even when there is no file in source folder. i want to trigger mail when there is a file in Source folder, and after processing the file mail should get triggered, so user can come to know that file which they placed in the folder is got processed. But in present scenario, because i used agent job, which is checking for the file every 1 hour, even if file is not there mail is getting triggered to user. Please help me on this.
Can any one please suggest how can i rectify it.
Thanks
Yes, there are numerous ways to handle this depending on what you want to do.
They all involve only sending the email if some condition is true. You will have to decide what that condition is, and then that will suggest the best way to handle it.
You can set a variable and use an expression in the precedence constraint to only go to the Send Mail Task if the variable is true, for example.
If you want to look at a more complicated set of conditions, you can use a script task.
I would have sent mail only if the package fails. Not sure, your purpose of sending mail to the Client.
If the issue is sending mail every 1 hour is too much for the client.
Send mail if package fails and keep the status of every hour in a file (Using Script task, use variable to get the current Hour and write the Hour and Status to file) and send a consolidated mail at the end like.
Date: 09/23/2016
Hr - STATUS
-------------
00 - SUCCESS
01 - FAILED
.
.
.
23 - SUCCESS
If you want to send the consolidated mail at particular time, use the Variable used in precedence constraint before the send mail task.
Edit:
As per your update on clarification. Create a boolean variable to get the existence of the file using script task. Use that variable in precedence constraint before the Send Mail task.
http://sql-articles.com/articles/bi/file-exists-check-in-ssis/
Also, Refer

Suppress MsgBoxes on launching Access OR Prevent form opening on launch?

To preface this, I messed up.
I have a function that runs for each item in the database, to compare against a given value. I added a MsgBox to the code in order to check values for debugging. This function runs when the default form for the project (the one that loads when I launch Access) loads-- on every record in the database. Currently, that's slightly over 13000 items.
Is there any way to suppress the messages, launch the project without loading that form, or edit VBA from the project without launching the project?
EDIT: I've just realized that I can press ESCAPE during a MsgBox display to abort the query. Problem solved.

CRM Plug-In Call retrieves a subset of Invoice Lines when creating an Invoice from an order

We are developing a CRM plug-in that would be triggered whenever an Invoice is Generated in CRM from an Order.
The typical action would be going to a Sales Order and clicking on “Create an Invoice”.
The end game of the plug-in is to integrate the Invoice into a Remote system along with the header and lines.
Plug-in works in the following way:
Plugin is registered with the CRM Invoice for the “Create” Event.
Plugin runs “Asynchronously” via a Post operation of the Invoice Header.
Upon hitting “Create Invoice”, UI Action; Plugin sends the newly created Invoice GUID to a service, this is typically a POST operation:
a. We Basically make a call to an ASPX page which accepts this request and processes it.
b. Processing includes steps by:
i. Getting the invoice header through a CRM Service Retrieve call.
ii. Getting the Invoice Lines through a CRM Service Retrieve multiple call.
c. Commit the Invoice to the 3rd Remote Application Database.
d. We respond to the Plug-in by wrapping any custom status or error messages.
All the processes finishes in less than a minute.
Scenarios We tested on our end:
Case 1:
Invoice Containing 5-10 Lines
Steps 3(a). till 3(d). runs successfully and integrated the Invoice with all the lines.
Case 2: ISSUE
Invoice Containing more than 10 (Tested with 15-40 lines)
Step 3b(ii) . Invoice Lines Retrieval process retrieves only some lines and not all the lines
Initially we thought, there could be a Read lock for the current Authenticated user for CRM SDK, as the logged in user was also same, when the CRM is creating lines for the Invoice.
But the test failed there too.
Successful Scenario Tested:
We retrieved the Invoice Lines separately through a different call by delaying the call for some seconds. The number of lines retrieved was successful. But not sure what delay the server would take.
We require your inputs on this issue to move forward in order to resolve this as we may be making some mistakes while doing this Plugin request call.
Thanks And Regards.
I know that this question is a year old but I'm still looking for a solution to it so I figure other people might be too.
My experience is that CRM needs to save (Create) the header record before it can associate the lines to it. Because you have registered it for Async execution, there is a slight delay before it executes which gives it time to have saved some of the lines before you try and load them.
So far my best solution is to trigger the plugin on the Create message of invoicelines, count all of the lines associated with that invoice and either pass a row count from the order or count the lines on the order and when they have the same count, execute your main body of code. It is pretty inefficient for orders with a lot of rows. But it is a solution.

ms-access: doing something on database open

is it possible to run a sub or function as soon as the user opens an access database file? if so, how?
Create your function:
Public Function DoSomething()
' do stuff '
End Function
Then create a macro with the run code action which calls your DoSomething function. Name the macro autoexec. Then, every time the data base starts up, it will run your autoexec macro.
Another thing you can do is set a form to open whenever the database starts. You could then call your DoSomething function from a form event (on open, or on load).
Choose one of those approaches. Either way, if you ever want to start the database without DoSomething running, hold down the shift key as the database opens to bypass your automatic startup routine.
You could open a hidden form on start up like in Access 2007 Startup.
This is also possible in older Access version.
You may use this hidden form for logging or other 'system'-related tasks.