• Jas Salesforce
  • NEWBIE
  • 1 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 4
    Replies
Hi Team, (this is my original question where Charu helped me but the code is not working, so adding more details for help please)
I got a junction object on Account for Account-Account relationship with one master-details field ( Account_to_c) and lookup field (Account_from) which is linking accounts to multiple accounts. 
i need to add duplication rule to avoid mulitple entries in 'Account to' and 'account from' field. Rule should check if Acount A's relationship exist in either Account to or Account from lookups then show a error when creating duplicate entry. 

Standard duplicate rules and workflow rule options are not working.


Thanks so much for the help, but it is firing up. code is as below, has no errors. Accounts relationship is a custom object has two fields Accounts to and account from added on accounts as related list so can add multiple account relationships. User can add new relationship from 'Account to' relationship related list and that will show up on reciprocal account in 'Account from' related list. Would like system should check duplicates in Account to and Account From related list when adding new relationship from 'Account to'  

---------------------------------------------------------------------------------------------------------------------------------------------------------
trigger PreventDuplicationonAccountrelationship on Account_Relationship__c  (before insert,before Update) {
Set <Id> AccFromId = new Set<Id>();
Set <Id> AccToId = new Set<Id>(); 
if(trigger.IsBefore &&(Trigger.IsInsert || Trigger.IsUpdate)){
    for (Account_Relationship__c Acc:trigger.new) {
        AccToId.add(Acc.Account_To__c);
        AcctoId.add(Acc.Account_From__c);
    }
}
    List <Account_Relationship__c> lstAcc = [SELECT Account_To__c,Account_From__c FROM Account_Relationship__c WHERE Account_To__c IN :AccToId  AND Account_From__c  in :AccFromId ];

    for (Account_Relationship__c Acc2:trigger.new) {
        If (lstAcc.size() > 0) {
            
          Acc2.Account_To__c.adderror( 'Duplicate Account Found' );
          Acc2.Account_From__c.adderror( 'Duplicate Account Found' );
            
        }
    }
}
----------------------------------------------------------------------------------------------------------------------------------
Object view, as you can see that i can add multiple accounts from 'Relationship to' related list and see same account added from 'Relationship from' list too. 

User-added image
 
Hi Team, 
I got a junction object on Account for Account-Account relationship with one master-details field ( Account_to_c) and lookup field (Account_from) which is linking accounts to multiple accounts. 
i need to add duplication rule to avoid mulitple entries in 'Account to' and 'account from' field. Rule should check if Acount A's relationship exist in either Account to or Account from lookups then show a error when creating duplicate entry. 

Standard duplicate rules and workflow rule options are not working.

Can someone please suggest a way or if it can achieve via trigger then please can help me to write trigger as  still a beginner with writing codes. 
I added a visualforce page into lightning tab, and want page to look like same as lightning detail page, but it doent fit properly. Beginer developer and need help please. Also not able to get inline editing 
User-added imagemy code
<apex:page standardController="Opportunity" lightningStylesheets="true"> <apex:form > <apex:pageblock mode="maindetail"> <style> body .bPageBlock .pbBody .grey .pbSubheader{ background-color:grey; } </style> <apex:outputPanel styleClass="light grey" layout="block" > <apex:pageBlockSection title="Opportunity Basic Information" > <apex:InputField value="{!Opportunity.What_s_happening_today__c}"/> <apex:InputField value="{!Opportunity.What_do_I_want_to_achieve__c}"/> </apex:pageBlockSection> <apex:pageBlockSection title="Opportunity Goal/Size" > <apex:inputField value="{!Opportunity.Stretegic_Objective__c}"/> <apex:inputField value="{!Opportunity.Quantity__c}"/> <apex:inputField value="{!Opportunity.Product__c}"/> <apex:inputField value="{!Opportunity.Amount}"/> </apex:pageBlockSection>  </apex:outputPanel> <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" hideOnEdit="editButton" /> <apex:commandButton action="{!save}" value="Save" Style="margin-left: 350px;"/> <apex:commandButton action="{!Cancel}" value="Cancel" Style="margin-left: 20px;"/> </apex:pageblock> </apex:form> </apex:page>

would like page to look like as below (stabdard detail page)

User-added image
Help Please,

can anyone help me please, how can i automate Opportunity naming convention using Workflow rule or as administrator. would like Project Name + account Name + location
Hi Team, (this is my original question where Charu helped me but the code is not working, so adding more details for help please)
I got a junction object on Account for Account-Account relationship with one master-details field ( Account_to_c) and lookup field (Account_from) which is linking accounts to multiple accounts. 
i need to add duplication rule to avoid mulitple entries in 'Account to' and 'account from' field. Rule should check if Acount A's relationship exist in either Account to or Account from lookups then show a error when creating duplicate entry. 

Standard duplicate rules and workflow rule options are not working.


Thanks so much for the help, but it is firing up. code is as below, has no errors. Accounts relationship is a custom object has two fields Accounts to and account from added on accounts as related list so can add multiple account relationships. User can add new relationship from 'Account to' relationship related list and that will show up on reciprocal account in 'Account from' related list. Would like system should check duplicates in Account to and Account From related list when adding new relationship from 'Account to'  

---------------------------------------------------------------------------------------------------------------------------------------------------------
trigger PreventDuplicationonAccountrelationship on Account_Relationship__c  (before insert,before Update) {
Set <Id> AccFromId = new Set<Id>();
Set <Id> AccToId = new Set<Id>(); 
if(trigger.IsBefore &&(Trigger.IsInsert || Trigger.IsUpdate)){
    for (Account_Relationship__c Acc:trigger.new) {
        AccToId.add(Acc.Account_To__c);
        AcctoId.add(Acc.Account_From__c);
    }
}
    List <Account_Relationship__c> lstAcc = [SELECT Account_To__c,Account_From__c FROM Account_Relationship__c WHERE Account_To__c IN :AccToId  AND Account_From__c  in :AccFromId ];

    for (Account_Relationship__c Acc2:trigger.new) {
        If (lstAcc.size() > 0) {
            
          Acc2.Account_To__c.adderror( 'Duplicate Account Found' );
          Acc2.Account_From__c.adderror( 'Duplicate Account Found' );
            
        }
    }
}
----------------------------------------------------------------------------------------------------------------------------------
Object view, as you can see that i can add multiple accounts from 'Relationship to' related list and see same account added from 'Relationship from' list too. 

User-added image
 
Hi Team, 
I got a junction object on Account for Account-Account relationship with one master-details field ( Account_to_c) and lookup field (Account_from) which is linking accounts to multiple accounts. 
i need to add duplication rule to avoid mulitple entries in 'Account to' and 'account from' field. Rule should check if Acount A's relationship exist in either Account to or Account from lookups then show a error when creating duplicate entry. 

Standard duplicate rules and workflow rule options are not working.

Can someone please suggest a way or if it can achieve via trigger then please can help me to write trigger as  still a beginner with writing codes. 
Hi All,
Can anyone suggest me Websites where I can give Salesforce Admin 201 &401 Mock Exams and test my preparation.

Thanks In Advance.