• Nash12345
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 10
    Replies
Hi All,

I'm trying to create a...well the title says it basically.

The code I currently have doesn't work as I"m getting an "Error: Compile Error: Illegal assignment from List<Purchase_Order__c> to Id at line 7 column 13"

Here's the code:

trigger AutoPopAccountIdOnPi on Purchase_Item__c (before insert) {
    for (Purchase_Item__c PIInloop : Trigger.new) {
        IF(PIInloop.Supplier__c = null) {
            List<Purchase_Order__c> POlist = [SELECT Supplier__c FROM Purchase_Order__c WHERE Name = :PIInloop.Supplier__c];
            
            If(POlist.size() > 0){
            PIInloop.Supplier__c = POlist;
            } else { PIInloop.Supplier__c = null;
            }
   }
}
}


Any advice would be much appreciated.

Thanks
 
From my understanding, partner communities users only have a limit of emailing 500 customers and are not able to install third party applications such as mail chimp.
 
Is there a way to bypass this limitation using apex?
 

Hello my fellow salesforcers,

I'm trying to auto-populate an account lookup field on a custom object (purchase item)  based on the account field on its parent object (purchase order) which, in turn, is a child object to account. 

What I know is workflows don't allow lookup field updates. I also know, or I think I know, that process builder cannot realise this action because the trigger for the auto-population to happen is based on an event prior to the purchase item record being created. 

So am i right to assume that the only way to achieve what I'm looking for if via an apex trigger with the "before create" at the top?

If so, is the following code suitable? I'm currently getting an error on line 11 as it is unable to recognize the relationship of the purchase order's account (supplier) lookup field:

trigger AutoPopulateAccountLookupOnPi on Purchase_Item__c (before insert, before update) {

    //get the Purchase Orders Id's and store it in a set.
    set<Id> POIdSet = new set<Id>();
    for(Purchase_Item__c co: trigger.new){
        if(co.Purchase_Order__c != null){
            opptyIdSet.add(co.Purchase_Order__c );
        }
    }

    //query the purchase order records and get the associated accounts.
    map<id, Purchase_Order__c > POMap = new map<id, Purchase_Order__c >{[SELECT id, Purchase_Order__r.Supplier__c FROM Purchase_Order__c WHERE Id IN: POIdSet]};

    //update the account value based on the purchase order in the record.
    for(Purchase_Item__c co: trigger.new){
        if(POMap.containsKey(co.Purchase_Order__c )){
            co.Account__c = POMap.get(co.Purchase_Order__c ).accountId;

Thanks in advance! 

I just created a visualforce page in sandbox for a custom object and have successfully deployed it onto production together with its controller but have trouble displaying the page for partner community users in production (whereas it displays properly in sanbox for partner community users).

All settings are the same on production and sandbox.

What I additionally did:

- grant access in the visualforcepage/securty by adding the systme admin profile to the page after deployment

Any help is much appreciated!

Hi All,

I'm trying to create a...well the title says it basically.

The code I currently have doesn't work as I"m getting an "Error: Compile Error: Illegal assignment from List<Purchase_Order__c> to Id at line 7 column 13"

Here's the code:

trigger AutoPopAccountIdOnPi on Purchase_Item__c (before insert) {
    for (Purchase_Item__c PIInloop : Trigger.new) {
        IF(PIInloop.Supplier__c = null) {
            List<Purchase_Order__c> POlist = [SELECT Supplier__c FROM Purchase_Order__c WHERE Name = :PIInloop.Supplier__c];
            
            If(POlist.size() > 0){
            PIInloop.Supplier__c = POlist;
            } else { PIInloop.Supplier__c = null;
            }
   }
}
}


Any advice would be much appreciated.

Thanks
 
From my understanding, partner communities users only have a limit of emailing 500 customers and are not able to install third party applications such as mail chimp.
 
Is there a way to bypass this limitation using apex?
 

Hello my fellow salesforcers,

I'm trying to auto-populate an account lookup field on a custom object (purchase item)  based on the account field on its parent object (purchase order) which, in turn, is a child object to account. 

What I know is workflows don't allow lookup field updates. I also know, or I think I know, that process builder cannot realise this action because the trigger for the auto-population to happen is based on an event prior to the purchase item record being created. 

So am i right to assume that the only way to achieve what I'm looking for if via an apex trigger with the "before create" at the top?

If so, is the following code suitable? I'm currently getting an error on line 11 as it is unable to recognize the relationship of the purchase order's account (supplier) lookup field:

trigger AutoPopulateAccountLookupOnPi on Purchase_Item__c (before insert, before update) {

    //get the Purchase Orders Id's and store it in a set.
    set<Id> POIdSet = new set<Id>();
    for(Purchase_Item__c co: trigger.new){
        if(co.Purchase_Order__c != null){
            opptyIdSet.add(co.Purchase_Order__c );
        }
    }

    //query the purchase order records and get the associated accounts.
    map<id, Purchase_Order__c > POMap = new map<id, Purchase_Order__c >{[SELECT id, Purchase_Order__r.Supplier__c FROM Purchase_Order__c WHERE Id IN: POIdSet]};

    //update the account value based on the purchase order in the record.
    for(Purchase_Item__c co: trigger.new){
        if(POMap.containsKey(co.Purchase_Order__c )){
            co.Account__c = POMap.get(co.Purchase_Order__c ).accountId;

Thanks in advance! 

I just created a visualforce page in sandbox for a custom object and have successfully deployed it onto production together with its controller but have trouble displaying the page for partner community users in production (whereas it displays properly in sanbox for partner community users).

All settings are the same on production and sandbox.

What I additionally did:

- grant access in the visualforcepage/securty by adding the systme admin profile to the page after deployment

Any help is much appreciated!