anteo / redmine_custom_workflows

Allows to create custom workflows for Redmine
http://www.redmine.org/plugins/custom-workflows
GNU General Public License v2.0
178 stars 72 forks source link

Custom tables plugin #314

Closed ashrafalzyoud closed 1 year ago

ashrafalzyoud commented 1 year ago

Hi all Can from your plugin git value from custom_tables plugin

picman commented 1 year ago

Try to formulate it better please. Your question makes no sence.

ashrafalzyoud commented 1 year ago

Thx for replying me fast I want use your plugin to execute in custom table plugin https://github.com/frywer/custom_tables

But I can't find the value or treat with it If I need custom field from the table there and write the code

AirTibu commented 1 year ago

Hi,

Use this code to get the custom table values:


CustomValue.where(:customized_id => self.custom_entity_ids,:customized_type =>'CustomEntity').detect {|v| v.custom_field.external_name == "Threat"}.try(:value)

You should change the "Threat" word to you table column name! This is the external name of custom_field as below picture shown:

image

The result of above code is:

1.1 Airborne particles/dust; Levegőben lévő részecskék/por

All rows with ";" separation.

I hope it helps!

ashrafalzyoud commented 1 year ago

im try this code

if self.custom_field_value(536) != self.custom_value_for(536).try(&:value) || self.custom_field_value(537) != self.custom_value_for(537).try(&:value)

     @aa =  CustomValue.where(:customized_id => self.custom_entity_ids,:customized_type =>'CustomEntity').detect {|v| v.custom_field.external_name == "AA"}.try(:value) 

    @bb = CustomValue.where(:customized_id => self.custom_entity_ids,:customized_type =>'CustomEntity').detect {|v| v.custom_field.external_name == "BB"}.try(:value)

    @combination_exists = !(@aa & @bb).empty?

errors.add(:base,"This   combination is exists!") if @combination_exists

end

but not working if u can help where the wrong @AirTibu

AirTibu commented 1 year ago

The problem is, that the code I wrote give you back string and you try to compare as array.

ashrafalzyoud commented 1 year ago

Ok what the correct code @AirTibu

AirTibu commented 1 year ago

Hi,

This code gives back array, what you can compare with other array:


@aa = CustomValue.joins("LEFT JOIN custom_fields ON custom_fields.id = custom_values.custom_field_id").where(custom_values: { customized_id:self.custom_entity_ids,customized_type:'CustomEntity'}, custom_fields: { name: 'AA'}).pluck(:value)

@bb = CustomValue.joins("LEFT JOIN custom_fields ON custom_fields.id = custom_values.custom_field_id").where(custom_values: { customized_id:self.custom_entity_ids,customized_type:'CustomEntity'}, custom_fields: { name: 'BB'}).pluck(:value)

errors.add(:base,"This   combination is exists!") unless (@aa & @bb).empty?

I hope it helps!