Switch into Update Mode after adding an Item
Sebastian Schweer
Hello,after i add a new article in the Item Master i want to go back to the article and the Mask shoud be in the Update-Mode.
I try the following code, but it woldn't work. What did i make wrong?
/**
* @Trigger Type: CSCODE
* @Trigger Action: Change_Values
* @Trigger Form Type: 150
* @Trigger Event Typ: FormDataAdd
* @Trigger Before Event: False
* @Trigger Form Mode: Add
*
*/
try
{
// get the current Form
Form currentForm = pVal.Form;
// get the Item Number of the Article i just added
string newKey = "";
newKey = TextEdit.GetFromUID(currentForm, "5").Value; // Item 5 = Item Number or ItemCode
// Switch Form to Find Mode
SwissAddonFramework.B1Connector.GetB1Connector().Company.GetNewObjectCode(out newKey);
currentForm.Mode = SwissAddonFramework.UI.Components.ModeComponent.FormModes.FIND;
// Enter the ItemCode of the added Article
TextEdit.GetFromUID(currentForm, "5").Value = newKey;
// Press the Find Button to search for that ItemCode
Button.GetFromUID(currentForm, "1").Click(SwissAddonFramework.UI.Components.Item.ClickType.Regular);
}
catch (Exception ex)
{
string msg = "Error occured in customize rule " + ex.Message;
customize.Messaging.Debug.WriteMessage(msg, SwissAddonFramework.Messaging.Debug.DebugLevel.Exception);
customize.Messaging.StatusBar.WriteError(msg);
}
return true;
Thanks for your help,
Sebastian
Matthias Müller
Hi Sebastian,does this code open the last added item,at least?
I can not see the row where is defined to switch into the update mode. You have to insert something like this:
after:
// Press the Find Button to search for that ItemCode
Button.GetFromUID(currentForm, "1").Click(SwissAddonFramework.UI.Components.Item.ClickType.Regular)
insert:
// Switch Form to UPDATE Mode
pVal.Form.Mode = SwissAddonFramework.UI.Components.ModeComponent.FormModes.UPDATE;
I hope that could help with my ugly english :)
best regards
matthias
Manuel Marhold
Hi Sebastian,what error do you get?
I think this line is unnecessary:
SwissAddonFramework.B1Connector.GetB1Connector().Company.GetNewObjectCode(out newKey);
Check if item "5" really contains the itemcode because you are in after-event and after adding an item the form gets cleared. If not, get the ItemCode in BeforeEvent and save it in a UserDataSource or a variable.
In AfterEvent do your code like now without the line mentioned above and get the ItemCode from UserDataSource or variable
0
Please sign in to leave a comment.
Comments
0 comments