You need to sign in to do that
Don't have an account?
sarvesh001
Custom settings
Hi,
I am using custom settings data in trigger to populate value in custom field.
I am using list custom settings and i have created field of datatype number in custom settings , My task is i have to use this value in trigger and every time trigger fired it has to be incremented. I have done this one but the issue is the number value is incremented like 1, 2, 3 ....., .
I want the number like 001,002,003.....
can any one suggest me.
Thanks,
Sarevsh.
I am using custom settings data in trigger to populate value in custom field.
I am using list custom settings and i have created field of datatype number in custom settings , My task is i have to use this value in trigger and every time trigger fired it has to be incremented. I have done this one but the issue is the number value is incremented like 1, 2, 3 ....., .
I want the number like 001,002,003.....
can any one suggest me.
Thanks,
Sarevsh.
for ex : You can modify your code like mentioned above.
All Answers
Important :
If this is what you were looking for then please mark it as a "SOLUTION" or You can Click on the "Like" Button if this was beneficial for you.
I have tried what you suggested but first time its working fine next onwards numbers like 2,3,4.........
trigger customdata on Lead (before insert, before update) {
List<Lead> listL= new List<Lead>();
integer month = Date.Today().Month();
integer year = Date.Today().Year();
Regions__c settings = Regions__c.getInstance('Region');
string sequencenumber = settings.leadsequencenumber__c;
for(Lead L:trigger.new){
if(L.Zone__c=='Africa'){
L.Lead_Sequence_No__c= 'AFA'+'-'+year+'-'+month+ '-'+sequencenumber ;
}
}
integer sequence1=Integer.valueof(sequencenumber);
sequence1 = sequence1+1;
String sequence2 = String.valueof(sequence1 );
settings.leadsequencenumber__c=sequence2;
update settings;
}
for ex : You can modify your code like mentioned above.
Thanks for replay problem is solved.
Thanks,
Sarevsh.