• Maimoona S.
  • NEWBIE
  • 15 Points
  • Member since 2014
  • Salesforce Developer
  • Elance

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 6
    Replies
I want to know what is the relation between asset and service contract in salesforce. 

Assets are linked to contract line items.

If an asset is "purchased" (picklist field on assets) that is linked to service contract's contract line item , is there any difference occur in serice contract or total value of service contract?

Thanks

Hi ,

I want to implement amendements (using custom object) with service contracts. Please can any one explain what is the concept of  service contracts and amendments in general and suggest the ways to implement this in salesforce.

Thanks in advance!
Hi there,

I have a requirement to create a service Contract when Opportunity is Cclosed won and copy all Opp line items to contract Line Items.

Here is the sample Code , there are two DMLs in the loop , one for ServiceContract and other for contractlineitem(that need service contract id). 

Map<Id,List<OpportunityLineItem>> OppLineItems = new Map<Id,List<OpportunityLineItem>>();

for(OpportunityLineItem ol : [Select opportunityId,UnitPrice, Quantity , Description From OpportunityLineItem where 
opportunityId IN: Trigger.new])
    {
    	List<OpportunityLineItem> tempList = new List<OpportunityLineItem>();
    	
    	if(OppLineItems.containskey(ol.opportunityId))
    	{
    		templist = OppLineItems.get(ol.OpportunityId) ; 	
    		templist.add(ol);
    		
    		OppLineItems.put(ol.OpportunityId,tempList);
    	}
    	else
    	{ 	
    		templist.add(ol);
    		
    		OppLineItems.put(ol.OpportunityId,tempList);		
    	}
}

//Create Service Contract and Contract Line Item

for(Opportunity o : Trigger.New)
        {
        	if(o.IsClosed && o.Iswon)
        	{
				 ServiceContract sc = new ServiceContract();
				 
				 sc.AccountId = o.AccountId;
				 sc.Name = o.Name;
				 sc.ApprovalStatus = 'Draft';
				 sc.StartDate = System.today();
				 insert sc;

                                 List<ContractLineItem> ContractLineInsert = new List<ContractLineItem>();
                                for(OpportunityLineItem ol : OppLineItems.get(o.Id)
                                {
                                             ContractLineItem cl = new ContractLineItem();
                                             cl.ServiceContractId = sc.Id;
                                             // some other field mapping from opp line item
                                             ContractLineInsert.add(cl);
                                 }
                                 //insert line item
                                 insert ContractLineInsert;
    
    	
        	}
        }

I have a workaround to avoid dml in loop is that insert service contract on Opportunity trigger , set some custom field that hold opportunity id on service contract.
And on ServiceContract add another trigger that will query opportunity line item relevant to opportunity (using custom field on servicecontract object that hold opportunity id) and insert them as contract line item. 

I want to know if there is any other way of avoiding DMLs in loop as this could cause DML limit.
We are using the Metadata API to inspect List View objects, and have managed to find the Filter Fields, but they are using a different naming convention.

For example the API name for Fax in Accounts is 'Fax', but in the Metadata name in the filter fields is ACCOUNT.PHONE2

The same mixing up of names seems to happen with ALL standard object, though custom objects & fields simply use the API Name.

Does anyone have any idea how we can map the Metadata name ( ACCOUNT.PHONE2) to the API Name (Account.Fax)?
I want to know what is the relation between asset and service contract in salesforce. 

Assets are linked to contract line items.

If an asset is "purchased" (picklist field on assets) that is linked to service contract's contract line item , is there any difference occur in serice contract or total value of service contract?

Thanks

Hi there,

I have a requirement to create a service Contract when Opportunity is Cclosed won and copy all Opp line items to contract Line Items.

Here is the sample Code , there are two DMLs in the loop , one for ServiceContract and other for contractlineitem(that need service contract id). 

Map<Id,List<OpportunityLineItem>> OppLineItems = new Map<Id,List<OpportunityLineItem>>();

for(OpportunityLineItem ol : [Select opportunityId,UnitPrice, Quantity , Description From OpportunityLineItem where 
opportunityId IN: Trigger.new])
    {
    	List<OpportunityLineItem> tempList = new List<OpportunityLineItem>();
    	
    	if(OppLineItems.containskey(ol.opportunityId))
    	{
    		templist = OppLineItems.get(ol.OpportunityId) ; 	
    		templist.add(ol);
    		
    		OppLineItems.put(ol.OpportunityId,tempList);
    	}
    	else
    	{ 	
    		templist.add(ol);
    		
    		OppLineItems.put(ol.OpportunityId,tempList);		
    	}
}

//Create Service Contract and Contract Line Item

for(Opportunity o : Trigger.New)
        {
        	if(o.IsClosed && o.Iswon)
        	{
				 ServiceContract sc = new ServiceContract();
				 
				 sc.AccountId = o.AccountId;
				 sc.Name = o.Name;
				 sc.ApprovalStatus = 'Draft';
				 sc.StartDate = System.today();
				 insert sc;

                                 List<ContractLineItem> ContractLineInsert = new List<ContractLineItem>();
                                for(OpportunityLineItem ol : OppLineItems.get(o.Id)
                                {
                                             ContractLineItem cl = new ContractLineItem();
                                             cl.ServiceContractId = sc.Id;
                                             // some other field mapping from opp line item
                                             ContractLineInsert.add(cl);
                                 }
                                 //insert line item
                                 insert ContractLineInsert;
    
    	
        	}
        }

I have a workaround to avoid dml in loop is that insert service contract on Opportunity trigger , set some custom field that hold opportunity id on service contract.
And on ServiceContract add another trigger that will query opportunity line item relevant to opportunity (using custom field on servicecontract object that hold opportunity id) and insert them as contract line item. 

I want to know if there is any other way of avoiding DMLs in loop as this could cause DML limit.

Hello everyone

 

I'm trying to make a button that creates a record of a object return the user to a specific page after they've saved and created the record.

 

Normally this is relatively simple, but when dealing with recordtype selection first, I'm having some trouble getting it to functionl correctly. Particularly, when I put the save_new_Url value in, instead of going directly to the create record page, it goes to the url I specified. Is there a way to set the parameter for save Url on the create record page?

 

the url I'm using is like so:

 

/setup/ui/recordtypeselect.jsp?ent=01I30000001kSPj&retURL=%2F'+O.Id+'&save_new_url=/apex/DemoRequestProductBulkAdd%3FCF00N30000007JPKN%3D'+O.Name+'%26CF00N30000007JPKN_lkid%3D'+O.Id+'%26CF00N30000007JPK9%3D'+O.Account.name+'%26CF00N30000007JPK9_lkid%3D'+O.AccountId+'%26retURL%3D%252F'+O.Id

 

Thanks in advanced.

 

 

  • September 22, 2011
  • Like
  • 0

Hi,

 

I wish to add a custom button or custom link to a salesforce.com object's page. For example add such a button to an Account or Opportunity.

My custom link/button will  Execute JavaScript.  I would like to add/use the object id from the Account/Opportunity on which the button exists to a javascript function.  Is there a way of retrieving the parent object ID on which the custom link or button will exist.

 

I know for the User object a function UserInfo.getUserId() which can be used. Is there a similar function (or other process) that can be used for an Account Object & for Opportunity objects?

 

Thanks.