on 08-21-2016 9:55 PM
Hello pros,
I have a specific business requirement that I'm not able to implement.
Purpose of the requirement :
ConsiderI have already in base hundreds of opportunities. I would like to create a button that fire a copy of all existing opportunities, or all existing filtered to the previous month.
Things I tried to do :
I created a "dumb/useless" Custom Object with a text field "dummy", created screens using "Screen scenario with thing based navigation" option then I created a BeforeSave script that will fetch for all Opportunities and will recreate them (basically : Opportunity.CreateWithRef(opportunity)).Problem here is not really the code part, but the fact that my script is never called. Tried also other proposed scripts :
They were not firing too.
To ensure that my code was not bugged, I tried a this.dummy = "blablabla" that should replace whats the user typed in the QC. Not working.
Giving up the previous solution, I had a look on the opportunity.owl, and as we cannot modify native screens, I tried to reproduce the following Copy Handler on my custom BO :
The problem here is that you are not allowed to fire Outports in a different namespace of the custom object. You are not allowed to add field from BO located in a different namespace too.
Please, tell me if I'm wrong or if I'm doing something wrong.
Any suggestions, advices, or workarounds would be really appreciated.
Thanks a lot.
Regards,
Michael
Hi,
You could try any of these:
1. Create XBO on opportunity and on BeforeSave copy the opportunity
2. Create Custom BO with Action and in Action query opportunity and create copy
3. If this activity of copying needs to be done routinely, then you could create MDRO
Thanks, Pradeep.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Thanks a lot for your suggestions.
I cannot figure out how to achieve your 2 & 3 suggestions (I dont know what is a "MDRO"), but I'm close to have something workings on the 1st point :
In the script file until the comment I put "C4C started to crash here".
I tried every line 1 by 1, commenting others, log off from C4C, cleaning web browser data (cache, cookies, etc...), relaunching web browser to start a new test.
Every line supposed to create an Opportunity make C4C crash.
Even a simple "Opportunity.Create(this)" is not working.
import ABSL as absl;
import AP.CRM.Global as global;
import AP.Common.GDT as apcgdt;
var FIRE_CLONING = "test";
if (this.Name.content == FIRE_CLONING)
{
// Pointers to fetch the last month opportunities
var qryOpportunities;
var paramOpportunities;
var resultOpportunities;
var date1 = Context.GetCurrentSystemDate();
// Connection to the Opportunity BO
qryOpportunities = Opportunity.QueryByElements;
// Populate the parameters collection for the query call
paramOpportunities = qryOpportunities.CreateSelectionParams();
// Get all the opportunities which StartDate is before the current Date
paramOpportunities.Add(qryOpportunities.SalesForecastExpectedProcessingDatePeriod.StartDate, "I", "LT", date1);
// Execute the query
resultOpportunities = qryOpportunities.Execute(paramOpportunities);
/*
C4C started to crash here.
Every line here has been tested one by one, commented and uncommented and they all make the system crash
at the creation
*/
// Set of Tests 1
Opportunity.Copy(this); // 1.1) ?
Opportunity.Create(); // 1.2) Should create an empty Opportunity ?
Opportunity.CreateWithReference(this); // 1.3) Should create an opportunity based on this one ?
// End Tests 1
// Test 2
foreach (var opportunity in resultOpportunities)
{
Opportunity.CreateWithReference(opportunity); // 2.1) Should create an opportunity foreach element found in the result query
Opportunity.Copy(opportunity); // 2.2) ?
}
// End of Test 2
// Test 3
var singleResult = resultOpportunities.GetFirst(); // Get the first element in the resultOpportunities
Opportunity.CreateWithReference(singleResult); // 3.1)
Opportunity.Copy(singleResult); // 3.2)
// End of Test 3
// Delete this opportunity (this delete works well)
this.Delete();
}
Thanks a lot for your help.
Regards,
Michael
Hi Michael,
Regarding Pradeeps suggestion of creating an MDRO - You should check these links regarding Mass Data Runs (MDR)
Regards, Emily.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.