• stoutstreet
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 2
    Replies

Hi, Can't seem to figure out as to why this piece of code always returns a Null value and always executes the if statement even when there is an entry in the table. Thanks


                   if (currentBuyerId.get(a.UserOrGroupId) == NULL){
                    //If UserOrGroupId does not exist
                    //Add records being shared with buyers into the array for later insert
                    relationShare.add(buyerShare);      
                }

 

**********************

 

trigger Buyer_Supplier_Share on mcbangalore__Relation__c (after insert,after update) {

AccountShare buyerShare = new AccountShare();
List<AccountShare> relationshare = new List<AccountShare>();
id badId = '00550000001DzCR';

//
if ( trigger.isInsert||trigger.isUpdate) {

    for(Relation__c relation:trigger.new) {
        
        //Retrieve every supplier sharing record and insert it into the Buyer Sharing table
        
         List<AccountShare> supplierShare= [Select AccountId, UserOrGroupId from AccountShare
                        where AccountId =:relation.Supplier__c];

        //Map the Ids and UserOrGroup Ids of the Buyer Record to prevent duplicate entries
    
        Map<Id, AccountShare> currentBuyerId = new Map<Id,AccountShare> ([Select UserOrGroupId,AccountId from AccountShare
                        where AccountId = :relation.Buyer__c]);
        
        for (AccountShare a :supplierShare) {   
        
            //Share the Buyer Account with the Sellers;
            buyerShare.AccountId = relation.Buyer__c;
            //Share the Seller Account with all the Buyer Contacts
            buyerShare.UserOrGroupId = a.UserorGroupId;
            
            //Set the access level
            buyerShare.AccountAccessLevel = 'edit';
            //Set the Sharing Reason
            //buyerShare.RowCause = schema.Relation__Share.Rowcause.Grant_Relationship__c;
        
            //Check if the UserOrGroupId already exists for this Id
                
                   if (currentBuyerId.get(a.UserOrGroupId) == NULL){
                    //If UserOrGroupId does not exist
                    //Add records being shared with buyers into the array for later insert
                    relationShare.add(buyerShare);      
                }

    
            } //For AccountShare a
        } //for trigger.new
    } //If (trigger.IsInsert)


//Insert Array into the database
Database.SaveResult[] buyerresult = Database.insert(relationShare,false);

//Process Errors

Hi,

 

I am trying to dynamically assign the language in a visualforce page based on the User's language defined in the personal information. Right now it is hard coded as

 

 

<apex:page language="fr" >.

...

 

</apex:page>

 

Is it possible to achieve this via global variables without the use of a custom controller ? Alternatively can we leverage Custom Settings to achieve this.

 

Thanks

Atirath

Hi,. I am trying to replicate the cook book recipe and I still get this error. Here is the script that I copied from the cook book. I tried this on IE and Firefox.

 

Thanks in advance for your help

*******************************************************************************************************************************

{!requireScript("/soap/ajax/20/connection.js")}
{!requireScript("/soap/ajax/20/apex.js")}

var idsToInsert = {!GETRECORDIDS($ObjectType.Account)};
var noteTitle = prompt("Please Enter the Note Title");
var noteBody = prompt("Please Enter the Body of the Note");
alert("Record length:" +idsToInsert.length);

if (idsToInsert.length) {

          // Making a synchronous call to apex

        var result = sforce.apex.execute("mcbangalore.Mass Note Insert", "insertNotes", {iTitle:noteTitle, iBody:noteBody,     iParentIds:idsToInsert});
                  
               alert(result[0] + "inserted");

} else if (idsToInsert.length == 0) {

        alert("Please select accounts to insert notes");
     

}

Hi,

 

I am trying to dynamically assign the language in a visualforce page based on the User's language defined in the personal information. Right now it is hard coded as

 

 

<apex:page language="fr" >.

...

 

</apex:page>

 

Is it possible to achieve this via global variables without the use of a custom controller ? Alternatively can we leverage Custom Settings to achieve this.

 

Thanks

Atirath

Hi,. I am trying to replicate the cook book recipe and I still get this error. Here is the script that I copied from the cook book. I tried this on IE and Firefox.

 

Thanks in advance for your help

*******************************************************************************************************************************

{!requireScript("/soap/ajax/20/connection.js")}
{!requireScript("/soap/ajax/20/apex.js")}

var idsToInsert = {!GETRECORDIDS($ObjectType.Account)};
var noteTitle = prompt("Please Enter the Note Title");
var noteBody = prompt("Please Enter the Body of the Note");
alert("Record length:" +idsToInsert.length);

if (idsToInsert.length) {

          // Making a synchronous call to apex

        var result = sforce.apex.execute("mcbangalore.Mass Note Insert", "insertNotes", {iTitle:noteTitle, iBody:noteBody,     iParentIds:idsToInsert});
                  
               alert(result[0] + "inserted");

} else if (idsToInsert.length == 0) {

        alert("Please select accounts to insert notes");
     

}