Basic: how to get/set values from other fields
Jeroen Swanborn
Hi all,I'm very new to Coresuite and I've scheduled a course in a few weeks, but I have a question in the meantime..
A customer of ours want to have a new folder on the Item Master Data Form with an overview (read only) of all his important fields.
I've created a Customize rule that is active on form 150 and on FormLoad. This creates the folder and shows a few labels and fields.
I have several problems:
1) How can I read an existing field and show the value in another field (I don't want to move the field, I would like to copy it and it's value)
2) If I open the Item Master Form I get the fields as non editable (as I would like) (but without the values, see 1) but when I load a product, the fields become editable and when I select another folder and go back to my new one, it shows the fields but the name of the folder is not highlighted, the previous selected folder stays selected. This is working correctly on the empty form.
This is the code for the creation of the folder:
Exception threadEx = null;
try
{
Form form = pVal.Form;
Folder overview = Folder.CreateNew(SwissAddonFramework.Utils.UniqueStringGenerator.Next());
overview.SetSizeAndPosition(1, 5, 150, 22);
overview.Value = "Overview";
overview.Pane = 19001;
overview.ValOn = "Overview";
overview.DataBind = DataBind.CreateNew("folder");
overview.DataBind.DataBound = true;
form.AddItem(overview);
form.Update();
overview.GroupWith("163");
overview.AddHandler_Click(SwissAddonFramework.UI.Components.ModeComponent.FormModes.ALL, new SwissAddonFramework.UI.EventHandling.ItemEvents.ClickEventHandler(delegate(SwissAddonFramework.UI.EventHandling.ItemEvents.Click eventVal) {
eventVal.Form.PaneLevel = 19001;
}));
My_DLL.ItemOverview.Reset(152, 205);
My_DLL.ItemOverview.AddLabelToForm(form, "TEST", "162", 0, 19001);
My_DLL.ItemOverview.AddLabelToForm(form, "Manufacturer", "114", 0, 19001);
My_DLL.ItemOverview.AddLabelToForm(form, "Shipping Type", "35", 1, 19001);
overview.Select();
form.Update();
return true;
}
catch (Exception ex)
{
threadEx = ex;
SwissAddonFramework.UI.Dialogs.MessageBox.Show(threadEx.ToString(), "OK");
return false;
}
And the code from the MyDLL (fake name since it contains our customer name
static int[] top = new int[2] {152,152};
static int[] left = new int[2]{5,300};
static int verticalSpace = 5;
static int horizontalSpace = 3;
public static void Reset(int tp, int lft)
{
top = new int[2] {tp,tp};
left = new int[2]{5,lft};
verticalSpace = 5;
horizontalSpace = 3;
}
public static void AddLabelToForm(Form form, string label, string uniqueID, int column, int pane)
{
Item item = Item.GetFromUID(form, uniqueID); ;
Item.ItemType itype = item.Type;
Item te = null;
if (itype.CompareTo(Item.ItemType.ComboBox)==0){
te = ComboBox.CreateNew(SwissAddonFramework.Utils.UniqueStringGenerator.Next());
((ComboBox)te).ValidValues = ((ComboBox)item).ValidValues;
}
else if (itype.CompareTo(Item.ItemType.TextEdit) == 0)
{
te = TextEdit.CreateNew(SwissAddonFramework.Utils.UniqueStringGenerator.Next());
}
else if (itype.CompareTo(Item.ItemType.CheckBox) == 0)
{
te = CheckBox.CreateNew(SwissAddonFramework.Utils.UniqueStringGenerator.Next());
}
else if (itype.CompareTo(Item.ItemType.ExtendedTextEdit) == 0)
{
te = ExtendedTextEdit.CreateNew(SwissAddonFramework.Utils.UniqueStringGenerator.Next());
}
else if (itype.CompareTo(Item.ItemType.Grid) == 0)
{
te = Grid.CreateNew(SwissAddonFramework.Utils.UniqueStringGenerator.Next());
}
else if (itype.CompareTo(Item.ItemType.Label) == 0)
{
te = Label.CreateNew(SwissAddonFramework.Utils.UniqueStringGenerator.Next());
}
else
{
}
Label lbl = Label.CreateNew(SwissAddonFramework.Utils.UniqueStringGenerator.Next());
lbl.Width = 100;
lbl.Height = 15;
lbl.Value = label;
lbl.Top = top[column];
lbl.Left = left[column];
lbl.FromPane = pane;
lbl.ToPane = pane;
form.AddItem(lbl);
//TextEdit te = TextEdit.CreateNew(SwissAddonFramework.Utils.UniqueStringGenerator.Next());
te.Width = 200;
te.Height = 15;
te.Top = top[column];
te.Left = left[column] + lbl.Width + verticalSpace;
te.FromPane = pane;
te.ToPane = pane;
form.AddItem(te);
form.Update();
if (itype.CompareTo(Item.ItemType.ComboBox) == 0)
{
((ComboBox)te).DisplayDesc = true;
((ComboBox)te).Selected.Value = ((ComboBox)item).Selected.Value;
((ComboBox)te).Selected.Description = ((ComboBox)item).Selected.Description;
}
else if (itype.CompareTo(Item.ItemType.TextEdit) == 0)
{
((TextEdit)te).Value = ((TextEdit)item).Value;
}
else if (itype.CompareTo(Item.ItemType.CheckBox) == 0)
{
((CheckBox)te).Checked = ((CheckBox)item).Checked;
}
else if (itype.CompareTo(Item.ItemType.ExtendedTextEdit) == 0)
{
((ExtendedTextEdit)te).Value = ((ExtendedTextEdit)item).Value;
}
else if (itype.CompareTo(Item.ItemType.Grid) == 0)
{
((Grid)te).DataTable = ((Grid)item).DataTable;
}
else if (itype.CompareTo(Item.ItemType.Label) == 0)
{
((Label)te).Value = ((Label)item).Value;
}
else
{
}
te.Enabled = false;
form.Update();
top[column] = top[column] + lbl.Height + horizontalSpace;
}
Paolo Manfrin
Hi Jeroen,in order to read and copy a value of an item to another item you could use something like:
TextEdit oTextEdit = TextEdit.CreateNew("NewUID"); // new text edit
oTextEdit.Value = TextEdit.GetFromUID(pVal.Form, "ItemUID1").Value; // read the value from another textedit
concering your second issue I have the feeling that you need to react to other events like OnFormDataLoad or ValueChanged.
here you have two options to resolve the issue:
1. you create customize rules to react on ValueChange / FormDataLoad
2. you use in the same rule some delegate to react on ValueChange / FormLoad events
Something like:
if(pVal.Form.Items.ContainsKey("ITEM_UID"))
{
// DO STUFF
}
else
{
SwissAddonFramework.UI.EventHandling.ItemEvents.FormActiveEventHandler delFormActivate = null;
try
{
delFormActivate = delegate (SwissAddonFramework.UI.EventHandling.ItemEvents.FormActivate ev)
{
try
{
pVal.Form.RemoveHandler(ModeComponent.FormModes.ALL, delFormActivate);
// DO STUFF (AGAIN)
}
catch(System.Exception exe)
{
MessageBox.Show("Error happened in FormActivate: " + exe.Message, "OK");
}
};
pVal.Form.AddHandler_Activate(ModeComponent.FormModes.ALL, null, delFormActivate);
}
catch(System.Exception ex)
{
pVal.Form.RemoveHandler(ModeComponent.FormModes.ALL, delFormActivate);
MessageBox.Show("Error happened in FormdataLoad / FormActivate: " + ex.Message, "OK");
}
}
hth
paolo
Jeroen Swanborn
Thanks! I'll try that...Do you know how to fix the problem of the tab not being highlighted?
It works correctly in search mode, but in every other it doesn't highlight the tab name, but it shows the fields.
[attachment=55:picture1.png]
[attachment=56:picture2.png]
Paolo Manfrin
Hi, you need to group the folders. Search for the forum entry "Folder / Tab on my own created form".Basically you've to do something like
Tab2.GroupWith(Tab1.UniqueID);
hth, paolo
Jeroen Swanborn
Hi Paolo,I'm already grouping the tabs. It works when I'm in search mode, but as soon as I go to an item and the fields get filled, the Overview tab is not highlighted (but it is working, so if you click on the tabs, you get the correct panel)
overview.GroupWith("163");
Michael Egloff
Hello Jeroen,this is a restriction of business one. you are only allowed to add a certain amount of additional folders on a window. this amount is different on the different sap forms.
see [url="http://forum.coresystems.ch/topic/3925-problem-with-activation-a-new-user-foler-in-a-system-form/page__p__14564__hl__folder__fromsearch__1#entry14564"]here[/url] for more information.
0
Please sign in to leave a comment.
Comments
0 comments