• Sunil Rathore
  • NEWBIE
  • 465 Points
  • Member since 2017


  • Chatter
    Feed
  • 15
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 74
    Replies
I currently have a requirement where I need to set up a workflow or process. When an Opportunity is marked as Closed Won, a custom date field on that Opportunity (Renewal_Date__c) should populate as 7/1/20xx (whatever the next year is). 

Does anyone have any hints as to the formula I should use here?
Hello,

I want to implement a validation rule in case to not et users modify a field.

I have a field picklist with values 
custom_picklist__c
Value: ABC, CDB.

I have a Check_box1_c

If the Check_box1_c is true and the custom_picklist__c =ABC, dont let user to modify.

How can i implement this vlaidation rule 

thanks you for suggestion 
  • September 13, 2019
  • Like
  • 0
Hello,

I have a field picklist with values 
custom_picklist__c
Value: ABC, CDB.

If the value ABC is clicked and clcked on Save button, i want to execute a trigger which will execute some logic

Question:
1) How can i execute the usecase ?
Detect =>the change of picklist to ABC, and click of Save button
Action 1=> i want to change a Technical field value (can i do it in is before)
Action 2=>call a API (shold i call in future method ?)

thank you for suggestion 
  • September 13, 2019
  • Like
  • 0
public class test5 {

  public list<string> lststatename{get;set;}
  public list<string> lstrating{get;set;}

 public test5(){
 
 
    string  jsonexample1 =  ' { "overalldata": [ {"stateName": "Andrapradesh",  "rating": 5.0 }, { "stateName": "Telangana",  "rating": 4.0 }, {"stateName": "Banglore",  "rating": 5.0 } , {"stateName": "Maharastra",  "rating": 4.5 }  ] } ';

   
     map<string,object>  metadatamap= (map<string,object>)json.deserializeuntyped(jsonexample1); 
     
      list<object>  values1= (list<object>)metadatamap.get('overalldata');
        
        
         lststatename= new list<string>();
         lstrating= new list<string>();
         
          for(object parsed : values1){
             
             
           map<string,object>  values = (map<string,object>)parsed;
             
             
            string statename = string.valueof(values.get('stateName'));
             string rating= string.valueof(values.get('rating'));
               
             lststatename.add(statename );
             lstrating.add(rating);
            
             }
       
 }
}
visualforce page:


 
<apex:page controller="test5" >

 <apex:form >
 
 <table>
  <tr>
    <th>states</th>
    <th>rating</th>
  </tr>
  
  <apex:repeat value="{!lststatename}" var="a">
  <apex:repeat value="{!lstrating}" var="b">
  <tr>
   
   <td>{!a}</td>
  
    
    <td>{!b}</td>
  </tr>
   </apex:repeat>
   </apex:repeat>
</table>
    
 
 </apex:form>
 
</apex:page>

hi ,  im getting the data  in the visualforce page , but the data is getting iterable when i use the repeat functionality inside the table , can anybody have the solution for this  ??it should not iterate again .. thanks in advance


 the data should not be get iterate again,
 
How can I see all the fields I add in the related list?
User-added image

User-added image
Only a maximum of 4 are seen?


 
Hi,
Criteria:
On create Opportunity record , the Job Object records will create with according to Opportunity 'Quntity' Field ex: if quntity is 5 then create 5 job records and opportunity 'Amount' set in Job Object divided by 5 ex: If quntity is 5 and Amount is 1000 , set 200 to each Job records
I did this but didn't work
Please answer it.
Thanks in Advance.
If(Trigger.IsAfter && Trigger.isInsert)
   {
       for(Opportunity opp : Trigger.New)
       {
           Decimal Amount = opp.Amount / opp.TotalOpportunityQuantity;
           
           List<job__c> listofjob = new List<job__c>();
           
           for(integer i = 1; i<=opp.TotalOpportunityQuantity; i++)
           {
               job__c ajob = new job__c(Name = 'Job'+i, Amount__c =Amount );
               listofjob.add(ajob);
           }
           
           if(listofjob.size()>0)
           {
               insert listofjob;
           }
       }
   }

 
Hello, I'm trying to create a soql query to pull account records that have a type of sub-customer. Additionally I'd like the accounts to not be linked to an association record  OR the accounts can be linked to a system record where the system record's server type is retired. Below is the following query I've created, but I get an error message of unexpected token: OR. Any help would be appreciated. 

SELECT Id, Name FROM Account WHERE Type = 'Sub-Customer'AND ID not IN (Select Account__c from Associations__c)
 OR ID IN SELECT Primary_Account__c, Server_Type__c from System__c where Server_Type__c == 'Retired'
  • August 30, 2019
  • Like
  • 0
Can someone please help me out here , I want the get the verification_status from the below response.I am not able to understand the approach.

[ { "address1":"Rua Padre Antônio D'ângelo 121", "address2":"Casa Verde", "address3":"02516-040 São Paulo SP", "components":{ "administrative_area":"SP", "dependent_locality":"Casa Verde", "country_iso_3":"BRA", "locality":"São Paulo", "postal_code":"02516-040", "postal_code_short":"02516-040", "premise":"121", "premise_number":"121", "thoroughfare":"Rua Padre Antônio D'ângelo", "thoroughfare_name":"Padre Antonio D'angelo", "thoroughfare_type":"Rua" }, "metadata":{ "latitude":-23.50948, "longitude":-46.66073, "geocode_precision":"Premise" }, "analysis":{ "verification_status":"Verified", "address_precision":"Premise" } } ]
I have created a custom object and a tab. However its not visible on the page layout and as a tab as well. 
Checked evrything below
Profiles
 Permission sets
App manager
Page layout

Nothing seems to work. Please help out
Trigger

trigger LeadTrigger on Lead(before insert, before Update) {

    if (trigger.isInsert && trigger.isBefore) {
        LeadTriggerHandler.onBeforeInsert(trigger.new);

    } else if (trigger.isUpdate && trigger.isBefore) {
        LeadTriggerHandler.onBeforeUpdate(trigger.new, trigger.oldMap);
    }
}
 
TrigerHandlerClass

public class LeadTriggerHandler {
  
    public static String STATUS_SELF_REPRESENTED = 'Self Represented';
    
  
    public static void onBeforeInsert(list <Lead> newLeadList){
        updateFldsOnLead(newLeadList, null);
    }

   
    public static void onBeforeUpdate(list <Lead> newLeadList, map <Id, Lead> oldLeadMap){
        updateFldsOnLead(newLeadList, oldLeadMap);
    }

    public static void updateFldsOnLead(list <Lead> newLeadList, map <Id, Lead> oldLeadMap){
        map<String, list<lead>> zipCodeLeadMap = new Map <String, list<lead>> ();

       for(Lead ld: newLeadList){
            if(ld.Status != STATUS_SELF_REPRESENTED && ld.PostalCode != null){
              
               
                if(!zipCodeLeadMap.containsKey(ld.PostalCode)){
                    zipCodeLeadMap.put(ld.PostalCode, new list<lead>());
                }
                zipCodeLeadMap.get(ld.PostalCode).add(ld);
            }

        }
        if(zipCodeLeadMap.size() > 0){
           
            for(Lead_WF_Configuration__mdt ldConfigCMD: [Select Id, Zip_Postal__c, State__c, County__c,OwnerID__c
                                                          From Lead_WF_Configuration__mdt]){
                                                
                for(String zip: zipCodeLeadMap.keySet()){
                    
                    if(String.valueOf(ldConfigCMD.Zip_Postal__c).contains(zip)){
                        
                        
                        for(Lead ld: zipCodeLeadMap.get(zip)){
                            ld.State = ldConfigCMD.State__c;
                            ld.County__c = ldConfigCMD.County__c;
                            ld.OwnerId = ldConfigCMD.OwnerID__c;
                        }
                 }
                 }
            }
        }
    }
}

 
Hi All,

 Can anyone please explain to me how do you handle production issues in your project. what is the approach? 
Do you use Jira tool to raise a ticket for the case?

Say for example if we have 100 users and if one user is not receiving the email sent out of 100 users. what approach can be followed? And how can we fix the issue?

Thanks,
Sirisha

I am trying to create a formula in Salesforce to count the number of spaces in a text string and determine if the count of total spaces is less than one.

Not sure if that is even possible, please let me know if you need more context. 

Hi,

I am able to cover Trigger.IsInsert & Trigger.IsUpdate but Trigger.IsDelete is not covering. Please check below test class and provide your suggestions.

Trigger:-
trigger CMC_Post_Tention_Weight_Rollup on OpportunityLineItem (after Insert, After Delete, After Update) 
{
Product2 productPostTensionWeight = [select id, name From Product2 where name = 'Post tension'];
    
if(trigger.isInsert)
{
List <OpportunityLineItem> postTensionWeight = trigger.new; //for update/Insert    
List<Id> listOptyIds = new List<Id>(); 
for(OpportunityLineItem eachOptyLineItem : PostTensionWeight ) 
    {
    listOptyIds.add(eachOptyLineItem.OpportunityId); 
    }

List <Opportunity> AllOppty = [Select ID, Name, Total_Post_Tension_Weight__c  from Opportunity 
                               where id in: listOptyIds];
for(Opportunity opty:AllOppty)
    {
    for(OpportunityLineItem PTW : postTensionWeight)
        {
          
        if(PTW.Product2Id == productPostTensionWeight.Id && PTW.OpportunityId == opty.Id)
            {   
            Opty.Total_Post_Tension_Weight__c = Opty.Total_Post_Tension_Weight__c + PTW.Post_Tension_Weight__c;   
            
            }
         }    
     }
update AllOppty;
}

if(trigger.isDelete)
{
List <OpportunityLineItem> postTensionWeight = trigger.Old; //for Delete    
List<Id> listOptyIds = new List<Id>(); 
for(OpportunityLineItem eachOptyLineItem : PostTensionWeight ) 
    {
    listOptyIds.add(eachOptyLineItem.OpportunityId); 
    }

List <Opportunity> AllOppty = [Select ID, Name, Total_Post_Tension_Weight__c  from Opportunity 
                               where id in: listOptyIds];
for(Opportunity opty:AllOppty)
    {
    for(OpportunityLineItem PTW : postTensionWeight)
        {
      
        if(PTW.Product2Id == productPostTensionWeight.Id && PTW.OpportunityId == opty.Id)
            {
           Opty.Total_Post_Tension_Weight__c = Opty.Total_Post_Tension_Weight__c - PTW.Post_Tension_Weight__c;   
            
            }
         }    
     }

update AllOppty;
}

if(trigger.isUpdate)
{
List <OpportunityLineItem> postTensionWeight = trigger.New;
List <OpportunityLineItem> OldpostTensionWeight = trigger.Old;    
List<Id> listOptyIds = new List<Id>(); 
for(OpportunityLineItem eachOptyLineItem : PostTensionWeight ) 
    {
    listOptyIds.add(eachOptyLineItem.OpportunityId); 
    }

List <Opportunity> AllOppty = [Select ID, Name, Total_Post_Tension_Weight__c  from Opportunity 
                               where id in: listOptyIds];
for(Opportunity opty:AllOppty)
    {
    for(OpportunityLineItem PTW : postTensionWeight)
        {
        For(OpportunityLineItem OPTW : OldpostTensionWeight)
        {        
        if(PTW.Product2Id == productPostTensionWeight.Id && PTW.OpportunityId == opty.Id && PTW.ID==OPTW.ID)
            {
      
            Opty.Total_Post_Tension_Weight__c = Opty.Total_Post_Tension_Weight__c - OPTW.Post_Tension_Weight__c + PTW.Post_Tension_Weight__c;   
            
            }
         }
        }     
     }

update AllOppty;
}
   


Test Class:- 

@istest(SeeAllData = true)
public with sharing class testupdateoppty{
 public static testMethod void TestdeletetonneageMethod() 
    {
      Opportunity op3 = new Opportunity(Name='Testoppthhhhhhssssde');
         
      op3.Bid_Date_Time__c = system.today();
      op3.CloseDate = system.today();
      op3.Market_Segment__c = 'Test1';
      op3.Stage_Structural__c = 'Planning';
      op3.State__c = 'AK';
      op3.City__c = 'Test';
      op3.Opportunity_Type__c = 'Test2';             
      op3.Referred_To__c = 'Test3';
      op3.Referred_From__c = 'Test4';
      op3.Sales_Office__c = 'Test6';
      op3.StageName = 'Planning';
      op3.Total_Loose_Dowel_Revenue__c = 1234;
      op3.Total_TBA_Revenue__c = 200000;
      op3.Total_Loose_Dowel_Revenue__c=1000;
      op3.Total_Loose_Dowel_Tons__c= 2000;
      op3.Dummy_Tonnage__c = 23 ;
      insert op3;
      
       Pricebook2 pb1 = [select Id from Pricebook2 where isStandard=true limit 1];                          
       Product2 prod1 = new Product2(Name = 'Loose Dowels123', ProductCode = 'LB');        
       insert prod1;
       
     
       
        PricebookEntry price = new PricebookEntry(
            
            Pricebook2Id = pb1.Id,
            UnitPrice = 1.0,
            IsActive = true,
            Product2Id = prod1.Id
            
            );
            insert price;
       
      
                 
      List<opportunityLineItem> opppro1 = new opportunitylineitem[]{new opportunitylineitem(UnitPrice=10000.00,
      Quantity=10,Total_Revenue__c = 10000.00, opportunityid=op3.id, pricebookEntryId=Price.id, Invoiced__c = TRUE)};
           
            insert opppro1;   
    
    op3.Dummy_Tonnage__c  = 50;
           update op3;
            
          Test.startTest();
           delete op3;
          Test.stopTest();
    }
}
 
  Is it possible to fetch details of the chat associated with a specific chat key in Snap-ins? Looking for a similar method like details fetched using getDetailsByChatKey() method in a live agent.
  Is it possible to fetch details of the chat associated with a specific chat key in Snap-ins? Looking for a similar method like details fetched using getDetailsByChatKey() method in a live agent.
I currently have a requirement where I need to set up a workflow or process. When an Opportunity is marked as Closed Won, a custom date field on that Opportunity (Renewal_Date__c) should populate as 7/1/20xx (whatever the next year is). 

Does anyone have any hints as to the formula I should use here?
Hi 
I have created a VF page and it call a custom extension controller.
In the custom extension conroller, if I use the below Select statement, it is throwing the error: 
List has no rows for assignment to SObject

String ProdName = csvRecordData[1];//From CSV file I am reading the data into a string Variable.
String name2 = [SELECT Id, Name FROM Product2 WHERE Name = :ProdName LIMIT 1].Name;

I am not sure what went wrong with the above query.

If I used as below, then it is working. 
String name2 = [SELECT Id, Name FROM Product2 WHERE Name = 'Test123' LIMIT 1].Name;

Thanks,
Naren
  • October 14, 2019
  • Like
  • 0
public without sharing class LawyerAddressAllocationSelector {

    public Map< Lawyer_Address_Allocation__c,String> selectByClosest(List<Id> lawyerIds, Double latitude, Double longitude) {
         Map< Lawyer_Address_Allocation__c,String>  DistWithAddr = new Map< Lawyer_Address_Allocation__c,String>();  
    for (Lawyer_Address_Allocation__c record:[Select Id,Start_Time__c, End_Time__c, Lawyer_Name__c, Lawyer_Name__r.Name,
                Office_Address__c, Office_Address__r.Geo_Coordinate__c,DISTANCE(Office_Address__r.Geo_Coordinate__c, GEOLOCATION(:latitude, :longitude), 'km') Dist
            From Lawyer_Address_Allocation__c
            Where (
                (Start_Time__c = null And End_Time__c = null)
                Or (Start_Time__c !=null And End_Time__c != null And End_Time__c >= TODAY)
            ) And Office_Address__c!=null AND Lawyer_Name__c in: lawyerIds
            Order by DISTANCE(Office_Address__r.Geo_Coordinate__c, GEOLOCATION(:latitude, :longitude), 'km'), Primary__c
            Limit 10000
                                             ]){
                                                 DistWithAddr.put(record,(String)record.get('Dist'));
    system.debug('Return'+ DistWithAddr) ;                                        }
    return DistWithAddr;
    }


List<Id> Lid=new List<Id>();
Lid.add('a0iO000000AUAESIA5');
Lid.add('a0iO000000AeLcAIAV');
LawyerAddressAllocationSelector.selectByClosest(Lid,-37.908700,144.741720);

Line: 4, Column: 33
Method does not exist or incorrect signature: void selectByClosest(List<Id>, Decimal, Decimal) from the type LawyerAddressAllocationSelector
Hello,

I am creating a reports on Contracts.
I filtered by date.

I dont see all the contracts.

is there any standard field that blocks the display of contracts in reports ?

thank you for suggestion
  • September 19, 2019
  • Like
  • 0
Hi All,
I want retrieve case records which from today to 2 years ago exactly. I have tried by using Last_N_DAYS:730. but it is giving even 2016 and before records also. I want only records between today and two years. Not before two years.
Can some please help me with SOQL query

Thanks in Advance!!

Regards,
Ramana
Hello,

I want to implement a validation rule in case to not et users modify a field.

I have a field picklist with values 
custom_picklist__c
Value: ABC, CDB.

I have a Check_box1_c

If the Check_box1_c is true and the custom_picklist__c =ABC, dont let user to modify.

How can i implement this vlaidation rule 

thanks you for suggestion 
  • September 13, 2019
  • Like
  • 0
Hello,

I have a field picklist with values 
custom_picklist__c
Value: ABC, CDB.

If the value ABC is clicked and clcked on Save button, i want to execute a trigger which will execute some logic

Question:
1) How can i execute the usecase ?
Detect =>the change of picklist to ABC, and click of Save button
Action 1=> i want to change a Technical field value (can i do it in is before)
Action 2=>call a API (shold i call in future method ?)

thank you for suggestion 
  • September 13, 2019
  • Like
  • 0
public class test5 {

  public list<string> lststatename{get;set;}
  public list<string> lstrating{get;set;}

 public test5(){
 
 
    string  jsonexample1 =  ' { "overalldata": [ {"stateName": "Andrapradesh",  "rating": 5.0 }, { "stateName": "Telangana",  "rating": 4.0 }, {"stateName": "Banglore",  "rating": 5.0 } , {"stateName": "Maharastra",  "rating": 4.5 }  ] } ';

   
     map<string,object>  metadatamap= (map<string,object>)json.deserializeuntyped(jsonexample1); 
     
      list<object>  values1= (list<object>)metadatamap.get('overalldata');
        
        
         lststatename= new list<string>();
         lstrating= new list<string>();
         
          for(object parsed : values1){
             
             
           map<string,object>  values = (map<string,object>)parsed;
             
             
            string statename = string.valueof(values.get('stateName'));
             string rating= string.valueof(values.get('rating'));
               
             lststatename.add(statename );
             lstrating.add(rating);
            
             }
       
 }
}
visualforce page:


 
<apex:page controller="test5" >

 <apex:form >
 
 <table>
  <tr>
    <th>states</th>
    <th>rating</th>
  </tr>
  
  <apex:repeat value="{!lststatename}" var="a">
  <apex:repeat value="{!lstrating}" var="b">
  <tr>
   
   <td>{!a}</td>
  
    
    <td>{!b}</td>
  </tr>
   </apex:repeat>
   </apex:repeat>
</table>
    
 
 </apex:form>
 
</apex:page>

hi ,  im getting the data  in the visualforce page , but the data is getting iterable when i use the repeat functionality inside the table , can anybody have the solution for this  ??it should not iterate again .. thanks in advance


 the data should not be get iterate again,
 
Hi All,
I am only trying to update a check box on an Opp object when stagename is changed to closed won but i get the following error

Compile Error: Variable does not exist: stagename at line 10 column 32

I want to write most of the code in the class not in the trigger .So please tell me how can i write this code in the class.



public class UpdateOppCheckBox
{
public static void UpdateOpp(List<opportunity>listOpps)
{
//list<opportunity>updte=new list<opportunity>();

for(opportunity opp1:ListOpps)
{

if(trigger.oldmap.get(opp1.id).stagename!=trigger.newmap.get(opp1.id).stagename && opp1.stagename=='closed won')
{
opp1.Update_Checkbox__c=true;
}
}

}



 
I want to make validation , but that error should not be thrown for users of pre defined 27 user roles.
What is the best way I can proceed with? 
- Hardcoding in validation rule?
- through apex (but where to store this list of roles, and in future if any modification required in the list, can it be configurable?)
I have the following formula in the process builder, however the date conditon is not working ie: if the date is greater than 60 days i am not getting the field update? how do correctthat
AND(

IF(NOT(ISBLANK([CampaignMember].ContactId )),TRUE,FALSE), 

IF([CampaignMember].Contact.HasOptedOutOfEmail==FALSE,TRUE,FALSE),

IF(NOT(ISBLANK([CampaignMember].Contact.AccountId)), true, false),

 CASE([CampaignMember].Contact.Account.Licensed_Mainframe__c,"Active", 1,0)=1, 

IF(ISBLANK( [CampaignMember].Contact.Last_Survey_Sent_Date__c)|| 

[CampaignMember].Contact.Last_Survey_Sent_Date__c >=today()-60, true, false)
Receiving same error message even after following instructions as per Trailhead and also the above-mentioned suggestion and not sure what is wrong, tried several time deleting and recreating as trailhead issue still persists please help
 
"Challenge Not yet complete... here's what's wrong:
The Sales Operation dashboard isn't configured according to the requirements. 1. The Bar chart, Gauge and Donut must measure Sum of Amount and must be named correctly. 2. The filter must be named Stage value. 3. The dashboard should run as the logged in user."

Thanks, Chandra
Hi,
What is the relationship between Account and Opportunity?


Thanks.
How can I see all the fields I add in the related list?
User-added image

User-added image
Only a maximum of 4 are seen?


 
I'm trying to create a table to provide metrics on the number of Account and Contact records grouped by state. So each state will have two number of count id.

Below is a code for my class and visual force page

Apex Class:
public with sharing class SampleController {
    public list<stateWrapper> recordlist { get; set;}
   public class stateWrapper {
		public String stateName;
		public Integer contactCount;
		public Integer accountCount;
		
		//Default constructor for innerClass
		public stateWrapper(
			String stateName, 
			Integer contactCount, 
			Integer accountCount
		){
			this.stateName = stateName;
			this.contactCount = contactCount;
			if ( contactCount == null ){
				contactcount = 0;
			}
			this.accountCount = accountCount;
			if ( accountCount == null ){
				accountCount = 0;
			}
			//the above this keyword denotes that we are talking about
			//the variables outside the constructor and not
			//the input parameters by the same name.
		}
	}

	public static Map<String,stateWrapper> calculateMetrics(){
		Map<String,stateWrapper> stateMap = 
			new Map<String,stateWrapper>();
		for ( AggregateResult ar : [	
			Select Count(id) cnt, BillingState state
			from Account 
			where BillingState != null 
			group by BillingState
		]){
			stateWrapper sw = new stateWrapper(
				(string)ar.get('state'),
				(integer)ar.get('cnt'),
				null
			);
			stateMap.put(sw.stateName,sw);
		}
		for ( AggregateResult ar : [	
			Select Count(id) cnt, MailingState state
			from Contact 
			where MailingState != null 
			group by MailingState
		]){
			stateWrapper sw = new stateWrapper(
				(string)ar.get('state'),
				null,
				null
			);
			if ( stateMap.containsKey(sw.stateName) ){
				sw = stateMap.get(sw.stateName);
			}
			sw.contactCount = (integer)ar.get('cnt');
			stateMap.put(sw.stateName,sw);
		}
		return stateMap;
	}
}

This is my visualforce page:
<apex:page controller="SampleController" >
      <apex:pageBlock >
        <apex:pageBlockTable value="{!recordlist}" var="a" title="My Badges" columns="4" align="center"  styleClass="table table-striped">
            <apex:facet name="header">Account and Contact State DashBoard </apex:facet> 
             <apex:column > <apex:facet name="header">State</apex:facet>
            {!a['stateName']}</apex:column>
             <apex:column > <apex:facet name="header">Number of Contacts</apex:facet>
            {!a['contactCount']}</apex:column>
             <apex:column > <apex:facet name="header">Number of Accounts</apex:facet>
            {!a['accountCount']}</apex:column>
        </apex:pageBlockTable>
      </apex:pageBlock> 
  </apex:page>

Screenshot of my visualforce page showing nothing:

User-added image
 
Hi,
Criteria:
On create Opportunity record , the Job Object records will create with according to Opportunity 'Quntity' Field ex: if quntity is 5 then create 5 job records and opportunity 'Amount' set in Job Object divided by 5 ex: If quntity is 5 and Amount is 1000 , set 200 to each Job records
I did this but didn't work
Please answer it.
Thanks in Advance.
If(Trigger.IsAfter && Trigger.isInsert)
   {
       for(Opportunity opp : Trigger.New)
       {
           Decimal Amount = opp.Amount / opp.TotalOpportunityQuantity;
           
           List<job__c> listofjob = new List<job__c>();
           
           for(integer i = 1; i<=opp.TotalOpportunityQuantity; i++)
           {
               job__c ajob = new job__c(Name = 'Job'+i, Amount__c =Amount );
               listofjob.add(ajob);
           }
           
           if(listofjob.size()>0)
           {
               insert listofjob;
           }
       }
   }