• Rizwan Ali 12
• NEWBIE
• 10 Points
• Member since 2019

• Chatter
Feed
• 0
• 0
• 0
Likes Given
• 1
Questions
• 4
Replies
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
```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 );
}

if(listofjob.size()>0)
{
insert listofjob;
}
}
}```

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
```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 );