+ Start a Discussion
Gasti2305Gasti2305 

Validation to Check Product Request has a Line Item

Hi Guys, in want to create a Validation Rule on PR or PRLI that check when the Status of the PR is changed to "send" it will works only when a PRLI (Product) ist added. So the User can not send a PR without any Items.

Anybody has a Tipp?
Thx.
 
AnkaiahAnkaiah (Salesforce Developers) 
Hi Gasti,

Can you confirm on which object have the status field? 
what is the relationship between PR & PRLI?

Thanks!!
mukesh guptamukesh gupta
Hi Gasti,

You can createa a formula field on PRLI Object that's will access PR Object==>>Status, and add your criteria

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh 
Gasti2305Gasti2305
Hi Mukesh,
thx for your help. 

At the PRLI i made a formula filed witch look at the PR - Status
TEXT(Parent.Status)

then a write in the PRLI - Validation Rule this formula.
When the PR - Status is send AND the Productname in PRLI ist empty the fire the Error - Message
 
IF( Status_PR__c = "Gesendet" &&  Product2.Name = NULL, true, false)

But it dont works. I check it other PRLI - Fileds but nothing works.

Where is my failuire :-).
Thx.
 
Gasti2305Gasti2305
Hi Ankaiah,

the Status is on the Produkt Request. 
I think that is the Question.. i found no relevant relation ship between PR and PRLI what can i use for this Check.  

What i want is this:
When the PR - Status (Picklist) is changed (from draft) to "send" AND )everything i can check on the PRLI) for examplae the Productname in PRLI ist empty.... the fire the Error - Message
AnkaiahAnkaiah (Salesforce Developers) 
Hi Gasti,

As per my understanding, you have  PR - Status picklist field & product lookup field  on PRLI object.
When you try to change the PR - Status from draft to send and there there is no product linked then you should not allow user to save the record.

 If my understanding is correct then try with below validation rule.
 
AND(ISCHANGED(Status_PR__c ), ISPICKVAL(Status_PR__c , 'Send'), ISBLANK(Productname__c))
If this helps, Please mark it as best answer.

Thanks!!




 
Gasti2305Gasti2305
Hi Guys, i found a solution.
The Product Request Line Items has Master - Detail Relationship to the Product Request.
I insert a new Rollup Summary - Filed "Line_Item_Counter__c" in the PR - Object (Count PRLI)
I added the Validation Rule with this formula:
Line_Item_Counter__c <= 0 && 
NOT( ISNEW()) && ISCHANGED(Status)
So it´s work great :-). 
Thanks for all support :-).