You need to sign in to do that
Don't have an account?
Swamy P
Developer forum Questions
Hello Everyone,
I would kike to know few of the answers to the below questions,
1. There are two fields, if the user populate two field values if we combine those values uniqueness should be maintained, how to achieve this without coding?
2.There are two workflow rules on the same object say namely wf1 and wf2. If wf1 fires then a field will be updated on the same object, if the field updated and due to this wf2 criteria meets then what will happen, wf2 will fire or not?
3. How many maximum groupings we can do for summary, matrix and join reports?
Thanks in advance!!
I would kike to know few of the answers to the below questions,
1. There are two fields, if the user populate two field values if we combine those values uniqueness should be maintained, how to achieve this without coding?
2.There are two workflow rules on the same object say namely wf1 and wf2. If wf1 fires then a field will be updated on the same object, if the field updated and due to this wf2 criteria meets then what will happen, wf2 will fire or not?
3. How many maximum groupings we can do for summary, matrix and join reports?
Thanks in advance!!
Hi,
1.) As per my understanding, if field1 value is "very" and value in field2 is "good" then you want a third field which should have "very good".So please create formula field for the same which will cocatenate the fields field1 and field2.
2.)Yes, wf2 will fire if the condition meets.
3.) Summary and joined reports can have up to three grouping levels. Matrix reports can have two row and two column groupings.
Thanks
Hope this helps you!
If not please let me know.
trigger ccOrderTrigger on ccrz__E_Order__c (before insert, after insert, after update) {
if(Trigger.isBefore) {
if(Trigger.isInsert) {
//PolicyTriggerHandler.beforeInsert(Trigger.new);
cc_OrderTriggerHandler.beforeInsert(trigger.new);
}
}
else if(Trigger.isAfter) {
if(Trigger.isInsert) {
//AccountTriggerHandler.afterInsert(Trigger.new);
cc_OrderTriggerHandler.afterInsert(Trigger.new);
}
}
if (Trigger.isBefore && Trigger.isInsert) {
for (ccrz__E_Order__c o : Trigger.new){
if(o.ccrz__EffectiveAccountId__C != null){
o.ccrz__Account__c = o.ccrz__EffectiveAccountId__C;
}
}
}
}
====================================Handler ====================================================================
public class cc_OrderTriggerHandler {
//all operations to be performed before an order is inserted
public static void beforeInsert(List<ccrz__E_Order__c> newList) {
/* Logic Added by Priyanka on 7/9/2020 - BEGIN */
Cache.Partition partition = Cache.Session.getPartition('local.order');
String OldOrderId = '';
set<String> PreviousOrderSequenceRecieved = new set<String>();
//String PreviousOrderSequenceRecieved = '';
PreviousOrderSequenceRecieved = (set<string>)partition.get('PreviousOrder');
System.debug('PreviousOrderSequenceRecieved>>>>>>>>>>'+PreviousOrderSequenceRecieved);
for(String OldOrd : PreviousOrderSequenceRecieved)
{
OldOrderId += (OldOrderId==''?'':',')+OldOrd;
}
System.debug('OldOrderIdCommaSeparatedOrder>>>>>>>>>>'+OldOrderId);
/* Logic Added by Priyanka on 7/9/2020 - END */
Set<String> sapCustomerIds = new Set<String>();
Map<String, ID> contactAddrMap = new Map<String, ID>();
Map<String, ID> accountMap = new Map<String, ID>();
for (ccrz__E_Order__c o : newList)
{
o.Ref_Order_Number__c = OldOrderId;
sapCustomerIds.add(o.SAP_Ship_To__c);
}
for(ccrz__E_ContactAddr__c ca : [SELECT ccrz__ContactAddrId__c, ID
FROM ccrz__E_ContactAddr__c
WHERE ccrz__ContactAddrId__c IN :sapCustomerIds])
{
contactAddrMap.put(ca.ccrz__ContactAddrId__c, ca.ID);
}
for(Account acc : [SELECT SAP_Account_Number__c, ID
FROM Account
WHERE SAP_Account_Number__c IN :sapCustomerIds])
{
accountMap.put(acc.SAP_Account_Number__c, acc.ID);
}
for (ccrz__E_Order__c o : newList) {
if (o.ccrz__Account__c == null && o.SAP_Sold_To__c != null ) {
o.ccrz__Account__c = accountMap.get(o.SAP_Sold_To__c);
}
if (o.ccrz__ShipTo__c == null && o.SAP_Sold_To__c != null) {
o.ccrz__ShipTo__c = contactAddrMap.get(o.SAP_Ship_To__c);
}
}
}
//all operations to be performed after an order is inserted
public static void afterInsert(List<ccrz__E_Order__c> newList) {
//Validate Future limits.
if (newList.size() > 50) {
for (ccrz__E_Order__c o : newList) {
o.addError('You cannot insert or update more than 50 Orders at a time.');
}
return;
}
//Validateion passed.
for(ccrz__E_Order__c o : newList) {
if(o.ccrz__OrderId__c == null){
ccOrderRestService.intgrateOrderById(o.Id);
}
}
}
public static void Passer(){
Integer i = 0;
i++;
i++;
i++;
i++;
i++;
i++;
i++;
i++;
i++;
i++;
i++;
i++;
i++;
i++;
i++;
}
}
=========================================test class =============================================================
@IsTest
private class CCOrderTest {
@isTest static void testSetAccountAndShipToOnOrder() {
Account testAccount = new Account(Name = 'TestOrderCompany', SAP_Account_Number__c ='123456', BillingCountry = 'GB');
insert testAccount;
ccrz__E_Order__c testOrder = new ccrz__E_Order__c(ccrz__Account__c =testAccount.Id, SAP_Created_Date__c = Date.today(), Order_Reason__c = 'OR', ccrz__BuyerCompanyName__c=testAccount.Name,
SAP_Ship_To__c=testAccount.SAP_Account_Number__c, Sales_Org__c='1000', ccrz__RequestDate__c=Date.today(),ccrz__OrderId__c='121212',
SAP_Sold_To__c=testAccount.SAP_Account_Number__c, ccrz__ExtCarrier__c='TestCarrier', Created_By_SAP_User_ID__c='SAPUSR', Order_Reason_Description__c='New Order',
ccrz__ShipAmount__c=1000, ccrz__PONumber__c='909909');
insert testOrder;
ccrz__E_ContactAddr__c CA = new ccrz__E_ContactAddr__c(ccrz__FirstName__c ='test');
insert CA;
testAccount = [select Id, Name from Account where Id = :testAccount.Id];
System.assertEquals(testAccount.Name, 'Test Account');
testOrder = [select Id, ccrz__Account__c, ccrz__ShipTo__c FROM ccrz__E_Order__c WHERE Id =: testOrder.Id];
System.assertEquals(testOrder.ccrz__PONumber__c, '909909');
}
/* @isTest static void testOrderIdAndPriceOnItem() {
Account testAccount1 = [SELECT Id, Name, SAP_Account_Number__c, Contact_Address__c FROM Account WHERE Name='TestOrderCompany' ];
ccrz__E_Order__c testOrder1 = [select Id, ccrz__Account__c, ccrz__ShipTo__c FROM ccrz__E_Order__c WHERE ccrz__PONumber__c = '909909'];
ccrz__E_OrderItem__c orderItem1 = new ccrz__E_OrderItem__c(ccrz__ExtName__c='121212', ccrz__Quantity__c=5,ccrz__SubAmount__c=2000, ccrz__Order__c = testOrder1.id);
insert orderITem1;
Account testAccount2 = [SELECT Id, Name, SAP_Account_Number__c, Contact_Address__c FROM Account WHERE Name='TestOrderCompany' ];
ccrz__E_Order__c testOrder2 = [select Id, ccrz__Account__c, ccrz__ShipTo__c FROM ccrz__E_Order__c WHERE ccrz__PONumber__c = '909909'];
ccrz__E_OrderItem__c orderItem2 = new ccrz__E_OrderItem__c(ccrz__ExtName__c='121213', ccrz__Quantity__c=0,ccrz__SubAmount__c=2000, ccrz__Order__c = testOrder2.id);
insert orderItem2;
orderItem1 = [SELECT ID, ccrz__Order__c, ccrz__Price__c from ccrz__E_OrderItem__c WHERE ccrz__ExtName__c='121212'];
System.assertEquals(testOrder1.ID, orderItem1.ccrz__Order__c);
System.assertEquals(400, orderItem1.ccrz__Price__c);
}*/
}