Auto update Sales Opportunity stages after adding new Sales Quote?
Is it possible to auto update the Sales Opportunity Stages(rows) after adding a new Sales Quote / Delivery / AR Invoice etc. ?
I can get info from the Sales Opportunity to the Sales Quote and visa versa but I am having problems selecting the Stages TAB and then adding rows. Any help or suggestions?
It should be possible to do something like this:
It should be possible to do something like this:
// Click the Stages tabFolder.GetFromUID(pVal.Form, "135").Click(Item.ClickType.Regular);// Add a row to the Matrix (by menu-click "Add Row")MenuItem.GetFromUID("1292").Activate();Regards,Anders
Thanks I will try this! :)
Thanks for your help!
What you suggested works perfect to move to stages tab and add a row. However now I sit with another problem. How do I add auto data to specific fields/columns in that newly added row? Normally I would use the item number to do a text edit but now the whole row's item number is the same?
My apologies for these "stupid" questions. I am just staring out and everything is still on a huge learning curve for me.
This is what I have code wise. It all works to open the correct linked Sales Opportunity from a Sales Quote and then open the Stages and add a row. Now lets say I want to add the date into the closing date field and also add the document type further down that row? What will the code be?
Perhaps there is a sample rule I can go look at?
Dim boNumber As String = TextEdit.GetFromUID(pVal.Form, "NI_00090").Value ' Get BO Number from SQ
Dim soNumber As String = TextEdit.GetFromUID(pVal.Form, "8").Value ' Get SQ Number from SQ
MenuItem.GetFromUID("2566").Activate() ' Open Sales opportunity
MenuItem.GetFromUID("1281").Activate() ' Change Document to FIND mode
Dim soForm As Form = Form.GetFormFromUID(customize.B1Connector.GetB1Connector().Application.Forms.ActiveForm.UniqueID) ' Set Document
TextEdit.GetFromUID(soForm, "74").Value = boNumber ' Set BO Number in Sales Opportunity
Button.GetFromUID(soForm, "1").Click(SwissAddonFramework.UI.Components.Item.ClickType.Regular) ' Press Find to open Sales Opportunity
Folder.GetFromUID(soForm, "135").Click(Item.ClickType.Regular) ' Select Stages TAB
MenuItem.GetFromUID("1292").Activate() ' Add Row in Stages
Don't worry, it's not a stupid question. We've all been new to this at some stage. I know it can be a lot to take in.
If you haven't already, download the coresuite framework development version from here:
There you will find documentation and samples of how to code using coresuite framework.
To answer your question about setting values in a matrix, here is an example using Oppurtunities:
In the last row: "5" is the column id, matrix.Rows.Count - 1 is the row number (starting at 0). In the case we want the last row. 5.5 is the value.
I hope this helps you.
Thanks for the documentation it will help a lot!
The rule works perfectly as a function button on a fully added Sales Quotation. Since the variables store the correct data from the added SQ.
However I would like to use it as a Optimizer rule on Form ADD. Trying it however gives me problems. Some of the data like the SQ DocNum, when adding the document the rule gets triggered and it tries to update the linked sales opportunity stages. It can not add certain info since it is not correctly stored in the system as yet. e.g. DocNum etc.
Is there a way around this?
// Get BO Number from SQ
String boNumber = TextEdit.GetFromUID(pVal.Form, "NI_00090").Value;
// Get SQ Number from SQ
String soNumber = TextEdit.GetFromUID(pVal.Form, "8").Value;
// Get Doc Owner Number from SQ
String sqOwner= TextEdit.GetFromUID(pVal.Form, "222").Value;
// Open Sales Opportunity
// Change SO Document to FIND
// Set Form
Form soForm = Form.GetFormFromUID(SwissAddonFramework.B1Connector.GetB1Connector().Application.Forms.ActiveForm.UniqueID);
// Enter BO to search
TextEdit.GetFromUID(soForm, "74").Value = boNumber;
// Press FIND button
// Change to Stages TAB
// Add Row in Stages
// Get the Matrix object
Matrix matrix = Matrix.GetFromUID(soForm, "56");
string dDay = DateTime.Today.ToString("yyyyMMdd");
// Set values in the last row
matrix.SetValue("1", matrix.Rows.Count - 1, dDay); // Start Date (Date values are set on the form yyyyMMdd)
matrix.SetValue("2", matrix.Rows.Count - 1, dDay); // Closing Date (Date values are set on the form yyyyMMdd)
matrix.SetValue("4", matrix.Rows.Count - 1, "3"); // Stage
matrix.SetValue("14", matrix.Rows.Count - 1, "23"); // Document Type
matrix.SetValue("15", matrix.Rows.Count - 1, soNumber); // Document Number
matrix.SetValue("67", matrix.Rows.Count - 1, sqOwner); // Doc Owner
// Press Update Button
Use the FormDataAdd event (don't select BeforeEvent) as the trigger in Optimizer. At that stage DocEntry/DocNum have been assigned.
Then, in your rule you can get the DocEntry of the Quotation as pVal.BusinessObjectKeyString. You can grab the DocNum from the UI at that stage.
Thanks for the info Anders!
But I have a problem now. When I Add a Quote, it opens a Sales Opportunity window and then run that opportunity window in an endless loop between Find and Add.
I added the pVal.BusinessObjectKeyString as my soNumber variable and changed the Optimizer rule to FormDataAdd.
What am I doing wrong?
Could you please export the rule to a cocu file and upload it here?
My apologies for taking so long the reply.
Here is the rule I worked on last. Was not sure how to upload it to the forum. So here is a public link to it. Let me know if it does not work for you.
Have you had any time to perhaps look at the rule? Any suggestions to fix it?