Showing posts with label Siebel MVG. Show all posts
Showing posts with label Siebel MVG. Show all posts

Monday 11 May 2020

MVG in Siebel : Association and Disassociation

Hello All,

This post is in continuation of my previous post http://www.siebelfoundations.com/2020/05/record-association-and-disassociation.html , Association and Disassociation in MVG applet.

So if the case arise wherein we have to write script of parent BC not the MVG BC. i.e. a case where Order is parent and Voucher is MVG BC, we have to write script on Order.

For Association of Records

The Steps are very simple.

1. Instantiate the Current BC (Order in this case)
2. Get MVG Bus comp from the field on which MVG is based
3. Get Assoc Bus comp from the MVG Bus Comp
4. Specify the search on the Assoc Bus comp
5. Trigger Associate Event


//Add Record in MVG -- Initiate BC - Get MVG BC from Field - Get Assoc BC - Fire Search Spec and Associate

var oNumber = "1-12345TXN";
var oBusObject = TheApplication().ActiveBusObject();
var oBusComp = oBusObject.GetBusComp("Order Entry - Orders");
with(oBusComp)
{
ActivateField("Voucher Number");
SetViewMode(AllView);
ClearToQuery();
SetSearchSpec("Order Number",oNumber);
ExecuteQuery(ForwardBackward);
if(FirstRecord())
{
var oMVGBuscomp = GetMVGBusComp("Voucher Number");
var oAssocBusComp = oMVGBuscomp.GetAssocBusComp();
with(oAssocBusComp)
{
ActivateField("Order Number");
ActivateField("Voucher Expiry Date");
ClearToQuery();
var expr = "[Order Number] = '"+oNumber+"' AND [Voucher Expiry Date] >= Today()";
SetSearchExpr(expr);
ExecuteQuery(ForwardBackward);
var isRec = FirstRecord();
while(isRec != "")
{
Associate(NewBefore);
isRec = NextRecord();
}
}
}
}

In case of deleting record from MVG 

The Steps are very simple.

1. Instantiate the Current BC (Order in this case)
2. Get MVG Bus comp from the field on which MVG is based
3. Specify the search and till no records left
5. Delete record


////Delete from MVG -- Initiate BC - Get MVG BC from Field  - Delete Record from MVG
var oNumber = "1-12345TXN";
var oBusObject = TheApplication().ActiveBusObject();
var oBusComp = oBusObject.GetBusComp("Order Entry - Orders");
with(oBusComp)
{
ActivateField("Voucher Number");
SetViewMode(AllView);
ClearToQuery();
SetSearchSpec("Order Number",oNumber);
ExecuteQuery(ForwardBackward);
if(FirstRecord())
{
var oMVGBuscomp = GetMVGBusComp("Voucher Number");
with(oMVGBuscomp)
{
ClearToQuery();
ExecuteQuery(ForwardBackward);
var rec = FirstRecord();
while (rec)
{
DeleteRecord();
rec = FirstRecord();
}
}
}
}

Here in this case we delete record from MVG Bus comp instance.

Tuesday 5 May 2020

Record Association and Disassociation in Siebel : MVG Applets

Hello All,

We have many time worked wth MVG Applets, where 2 Applets opens in Form of Shuttle applet.
The one of left is Associate applet and Right is MVG Applet.

When we Move record from Assoc to MVG is called Association, and Removing/Deleting from MVG is called Disassociation.



Recently i had a requirement wherein i had to perform Association, and update some field in Asso BC to keep some check
i.e. Suppose we are associating a custom entity "Vouchers" with a Account, and once we associate the Voucher we want to update a field in Voucher say Account Name, so that it does not appear again in Assoc list to prevent it from multiple tagging

and the same way we wanted to Nullify the Field, Account Name on the Voucher when Disassociation happen.

Choosing the Events:

Association triggers Associate Event of Corresponding Business Component, so update a field value of assoc BC when Association happen we will have to write script in Associate Event.


function BusComp_Associate ()
{
var AccNum = this.ParentBusComp().GetFieldValue("CSN Number");//to get the field in corresponging parent BC
ActivateField("Account Number"); 
SetFieldValue("Account Number", AccNum);       
WriteRecord(); 

}

There is no such event Disassociate in siebel, rather DeleteRecord is triggered when Disassociation occurs, so to remove the field value we can use Delete event.
I am using preDelete event, to make my code run before the record is deleted.

function BusComp_PreDeleteRecord ()
{
ActivateField("Account Number"); 
SetFieldValue("Account Number", ""); 
WriteRecord(); 
return (ContinueOperation);
}

we will explore how to associate/disassociate from different BC, in our next post

Siebel GoTo View - Handling Realtime cases

 Hello All,  We all must have used GoTo view functionality of siebel to navigate to a particular view from current view. What if the require...