You need to sign in to do that
Don't have an account?
Mrityunjay Patel 18
how to get the specific id only without using loop in list
List<order> odr = [select id,odname from order where odname =:'xyz'];
if(odr.size() > 0 && insodr.id != null)
{
for(order od:odr)
{
od.OpportunityId = insodr.id;
update od;
}
}
if(odr.size() > 0 && insodr.id != null)
{
for(order od:odr)
{
od.OpportunityId = insodr.id;
update od;
}
}
The above code wil not work since you are trying to update order id in the opportunity lookup, but if you dont want to loop put a where condition on the id in the soql itself otherwise you have to loop.
You have to add any unique field in the query if you have. Because in your query might be possible there are multiple records on the same name, so please add the Unique field and query on that and try to add more fields name in the query if in the record any unique value.
Please mark it as the best answer, if it helps in any way.
Thanks!