• VIVEK 998
  • NEWBIE
  • 50 Points
  • Member since 2015

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 2
    Likes Given
  • 0
    Questions
  • 15
    Replies
Now i want to apply this trigger and formula field values for existing records also,Can you pleas any one tell how to update this

I want to update the custom field - Finish_Code__c from PBSI__PBSI_Item__c object..please help me anyone
Hi All,

I got the below runtime error,please suggest on this.

Apex script unhandled trigger exception by user/organization: 00570000004Tasp/00D900000008xzp

Opportunitytrigger: execution of BeforeUpdate

caused by: System.QueryException: List has no rows for assignment to SObject

Trigger.Opportunitytrigger: line 3, column 1

My Trigger Code is like:
trigger OpportunityTrigger on Opportunity(before insert,before update,after insert , after update , before delete) 
{
    User validuser=[select Namespace.Active__c,Namespace.Pset__c,Namespace.code__c from User where Id=:UserInfo.getUserId()];

   if(validuser.Namespace.Active__c==true && validuser.Namespace.Pset__c==true && validuser.Namespace.code__c!=null)
   {

      //code

    }
I have a trigger that uses the account name to populate the service contract on the case. I have come across a few instances where we need to change the contact and account on the case so we delete the following off the case:
1. Service Contract
2. Account
3. Contact (then add a new contact)
Once I press save it errors with caused an unexpected exception, contact your administrator: Trigger: execution of AfterUpdate caused by: System.FinalException:Record is read-only: Trigger. Trigger line 9,column 1

The trigger is
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
trigger UpdateServiceContract on Case (before insert,before update, after update) {
  Id caseRecordTypeId = [Select id from RecordType where sObjectType = 'Case' and developerName ='Service_Desk' ].id ; 
    for (Case c : trigger.new) {
    if (c.RecordTypeID == caseRecordTypeId )
      if (c.service_contract__c == NULL){
        try{
          //c.Service_Contract__c = [select Id from ServiceContract where AccountId ='810D0000000Cfza' and Primary_Service_Contract__c = True].id;
        c.Service_Contract__c = [select Id from ServiceContract where AccountId = :c.AccountId and Primary_Service_Contract__c = True limit 1].id;
        }catch(QueryException e) {
          //No records found. Maybe you should set it to Null
      }
     }
    }
  
}

How do I amend the trigger to accomadate for the deletion of an account and service contract and a new contact is added?
Now i want to apply this trigger and formula field values for existing records also,Can you pleas any one tell how to update this

I want to update the custom field - Finish_Code__c from PBSI__PBSI_Item__c object..please help me anyone
Hi all,

Below is my code.

If(leadList[0].Sector__c=='Salaried'){
            If(mbd.Score__c >=600 && mbd.Score__c<650){
                leadList[0].Interest_Rate__c = 12.00;
            }else if(mbd.Score__c >=650 && mbd.Score__c<700){
                leadList[0].Interest_Rate__c =11.25;
            }else if(mbd.Score__c>=700 && mbd.Score__c<750){
                leadList[0].Interest_Rate__c = 10.25;
            }else if(mbd.Score__c>=750){
                leadList[0].Interest_Rate__c = 8.25;
            }else if(mbd.Score__c==-1){
                leadList[0].Interest_Rate__c = 12.75;
            }else if(mbd.Score__c==4){
                leadList[0].Interest_Rate__c = 11.25;
            }else if(mbd.Score__c == 5){
                leadList[0].Interest_Rate__c = 11.25;
            } 
        }else if(leadList[0].Sector__c=='SENP' && leadList[0].Sector__c=='SEP'){
            if(mbd.Score__c >=700 && mbd.Score__c<750){
                leadList[0].Interest_Rate__c = 10.25;
            }else if(mbd.Score__c >=750){
                leadList[0].Interest_Rate__c = 9.25;
            }else if(mbd.Score__c==4){
                leadList[0].Interest_Rate__c = 12.00;
            }else if(mbd.Score__c==5){
                leadList[0].Interest_Rate__c = 12.00;
            }
        }              
    }
    // Calculating Proposed EMI
 leadList[0].Proposed_EMI__c = (leadList[0].Amount_in_Rs__c+(leadList[0].Amount_in_Rs__c*leadList[0].Interest_Rate__c*leadList[0].Loan_Tenor_in_Month__c)/12)/leadList[0].Loan_Tenor_in_Month__c;
    system.debug('proposed emi--'+leadList[0].Proposed_EMI__c);

At Proposed EMI am getting Zero(0) even i have all the field values. What is the problem please let me know.

Thanks
We have two Visualforce pages that were created for opportunities. Everything is working fine in a normal browser.However, only the edit button shows up in Salesforce1
All of the security is the same for both pages.(Note: Both the Edit and New button for opportunities have been overridden to their respective VF page).
 
Hi
I am unable to connect with the facebook from salesforce.Let me kow the connection in detail steps.
Help me .
Thank you
Sridhar
Hi All,

I got the below runtime error,please suggest on this.

Apex script unhandled trigger exception by user/organization: 00570000004Tasp/00D900000008xzp

Opportunitytrigger: execution of BeforeUpdate

caused by: System.QueryException: List has no rows for assignment to SObject

Trigger.Opportunitytrigger: line 3, column 1

My Trigger Code is like:
trigger OpportunityTrigger on Opportunity(before insert,before update,after insert , after update , before delete) 
{
    User validuser=[select Namespace.Active__c,Namespace.Pset__c,Namespace.code__c from User where Id=:UserInfo.getUserId()];

   if(validuser.Namespace.Active__c==true && validuser.Namespace.Pset__c==true && validuser.Namespace.code__c!=null)
   {

      //code

    }
Hi,

I am redirecting to record url when the submit button is clicked from vf page. This is working fine in non service cloud and service cloud. 
But in service cloud, url is redirected to record and it is looking like non service cloud. It is coming out from service console. So i need to redirect to to the record of service console. How can i solve this issue.

Is there any direct method to know whether the console is service or not?? from apex class. Please help me out.Thanks in advance

Thanks,
Lakshmi
Hello,

I'm using a visualforce button in custom object layout page to create related list record of another custom object. when I use the sforce.one.createrecord the SF1 navigate to the create record page but I cannot auto populate the fields just like in standard salesforce when I passed parameters in url.
the creation page looks like this:
User-added image 
The lookup fields in yellow should present a read only value that is taken from a parameter passed from.
Any solution for this or a workaround?

Hi,

 

Can you please help on how to use sforce.one.createRecord function. I'm trying to redirect the user to standard new event page using this function on click of a link. But the page simply refreshes. Below is my code. Please help.

 

function createEvent(){
sforce.one.createRecord('Event', null);
}

 

<apex:outputLink  onClick="createEvent()">New Event</apex:outputLink>

  • December 09, 2013
  • Like
  • 1

Posting this in order to help others who, months from now, might Google "OP_WITH_INVALID_USER_TYPE_EXCEPTION" and find this explanation.

 

We wrote an Apex trigger on the User object, to insert a custom object record anytime a user updates their Chatter status.  This was done to fulfill a client's requirement to audit all Chatter activity.

 

The trigger worked fine, until one day the client signed up some Chatter Free users.  When such a user tried to update their status, they got a pop-up with an OP_WITH_INVALID_USER_TYPE_EXCEPTION error.

 

We scratched our collective heads for awhile.  After all, Apex triggers run in "system mode," right?  That is supposed to mean that "object and field-level permissions of the current user are ignored."  And yet this trigger seemed like it was running in "user mode," enforcing restrictions based on who the current user was.

 

The root cause turned out to be that a Chatter Free user cannot be the owner of a custom object record, and SFDC by default sets the current user as a new record's first owner.  We discovered this when we realized, via experiment, that Apex triggers fired as the result of actions by Chatter Free users could definitely update an existing record, but were having problems creating records.

 

So the simple solution was to explicitly set the owner of the new record to some fully-licensed user prior to inserting it.

When someone takes the time/effort to repspond to your question, you should take the time/effort to either mark the question as "Solved", or post a Follow-Up with addtional information.  

 

That way people with a similar question can find the Solution without having to re-post the same question again and again. And the people who reply to your post know that the issue has been resolved and they can stop working on it.