Skip to main content
Question

Sync Rule: After reinitialization, list is correct, but not after a record is added


JuniSihombing
Hero (Customer)
Forum|alt.badge.img+11

Hi,

I have a requirement to exclude the PART_USAGE.PART_LINE_CODE = ‘C_PDO’ from the list.

After initialization the result is correct.

But once I add a part usage which has part_line_code = ‘C_PDO’ inserted the the list will show the increasing number ( including PART_USAGE.PART_LINE_CODE = ‘C_PDO’ in the list)

 

Example here: after reinitialization, the list = 4.  

Add part-usage C_PDO, the list = 5.

Do reinitialization, the list = 4

 

The PART_USAGE sync rule:

 

Ownership Query:

<hierarchy_select>
 <primary_table>task_assignment_view</primary_table>
 <from>
  <table>task_assignment_view</table>
 </from>
 <attrs>
  <attr>task_assignment_view.person_id</attr>
 </attrs>
 <where>
  <data_constraint>
   <constraint>
    <left_operand>task_assignment_view.task_id</left_operand>
    <operator>eq</operator>
    <right_operand>{task_id}</right_operand>
   </constraint>
  </data_constraint>
 </where>
</hierarchy_select>

 

Initial Query:

<hierarchy_select return_only_requested_attrs="true" max_rows="50000">
  <primary_table>part_usage</primary_table>
  <attrs>
    <attr>part_usage.*</attr>
    <attr>part_usage_lot.*</attr>
  </attrs>
  <from>
    <table>part_usage</table>
    <table>part_usage_lot</table>
    <table>task</table>
    <table>task_assignment_view</table>
  </from>
  <where>
    <data_constraint>
      <constraint>
        <left_operand>TASK_ASSIGNMENT_VIEW.PERSON_ID</left_operand>
        <operator>eq</operator>
        <right_operand>{PERSON_ID}</right_operand>
      </constraint>
      <and/>
      <constraint>
        <left_operand>task.status</left_operand>
        <operator>eq</operator>
        <right_operand>OP</right_operand>
      </constraint>
      <and/>
      <parens>
        <constraint>
          <left_operand>task.task_status</left_operand>
          <operator>eq</operator>
          <right_operand>OPEN</right_operand>
        </constraint>
        <or/>
        <constraint>
          <left_operand>task.task_status</left_operand>
          <operator>eq</operator>
          <right_operand>ASSIGNED</right_operand>
        </constraint>
        <or/>
        <constraint>
          <left_operand>task.task_status</left_operand>
          <operator>eq</operator>
          <right_operand>COMMITTED</right_operand>
        </constraint>
        <or/>
        <constraint>
          <left_operand>task.task_status</left_operand>
          <operator>eq</operator>
          <right_operand>ACCEPTED</right_operand>
        </constraint>
        <or/>
        <constraint>
          <left_operand>task.task_status</left_operand>
          <operator>eq</operator>
          <right_operand>ENROUTE</right_operand>
        </constraint>
        <or/>
        <constraint>
          <left_operand>task.task_status</left_operand>
          <operator>eq</operator>
          <right_operand>ARRIVED</right_operand>
        </constraint>
        <or/>
        <constraint>
          <left_operand>task.task_status</left_operand>
          <operator>eq</operator>
          <right_operand>IN PROCESS</right_operand>
        </constraint>
        <or/>
        <constraint>
          <left_operand>task.task_status</left_operand>
          <operator>eq</operator>
          <right_operand>RECEIVED</right_operand>
        </constraint>
      </parens>   
      <and/>
     <constraint>
       <left_operand>part_usage.part_line_code</left_operand>
       <operator>ne</operator>
       <right_operand>C_PDO</right_operand>
     </constraint>
    </data_constraint>
    <join_constraint>
      <constraint>
        <left_operand>part_usage.task_id</left_operand>
        <operator>eq</operator>
        <right_operand>task.task_id</right_operand>
      </constraint>
      <constraint>
        <left_operand>part_usage.pu_id</left_operand>
        <operator>left_outer</operator>
        <right_operand>part_usage_lot.pu_id</right_operand>
      </constraint>
      <constraint>
        <left_operand>task.task_id</left_operand>
        <operator>eq</operator>
        <right_operand>task_assignment_view.task_id</right_operand>
      </constraint>
    </join_constraint>
  </where>
</hierarchy_select>

 

I have tried to set the Related Query same as Initial Query.  The list is still having C_PDO part-usage.

Tried setting the Related Query like this:

<hierarchy_select return_only_requested_attrs="true" max_rows='50000'>
	<primary_table>PART_USAGE</primary_table>
	<from>
		<table>PART_USAGE</table>
		<table>PART_DISP</table>
		<table>PART_USAGE_LOT</table>
	</from>
	<attrs>
		<attr>PART_USAGE.*</attr>
		<attr>PART_DISP.*</attr>
		<attr>PART_USAGE_LOT.*</attr>
	</attrs>
	<where>
		<data_constraint>
			<constraint>
				<left_operand>PART_USAGE.PU_ID</left_operand>
				<operator>eq</operator>
				<right_operand>{PU_ID}</right_operand>
			</constraint>
			<constraint>
				<left_operand>PART_USAGE.part_line_code</left_operand>
				<operator>ne</operator>
				<right_operand>C_PDO</right_operand>
			</constraint>
		</data_constraint>
		<join_constraint>
			<constraint>
				<left_operand>PART_USAGE.PU_ID</left_operand>
				<operator>left_outer</operator>
				<right_operand>PART_DISP.PU_ID</right_operand>
			</constraint>
			<constraint>
				<left_operand>PART_USAGE.PU_ID</left_operand>
				<operator>left_outer</operator>
				<right_operand>PART_USAGE_LOT.PU_ID</right_operand>
			</constraint>
		</join_constraint>
	</where>
</hierarchy_select>

 Or like this:

<hierarchy_select return_only_requested_attrs="true" max_rows='50000'>
	<primary_table>PART_USAGE</primary_table>
	<from>
		<table>PART_USAGE</table>
		<table>PART_USAGE_LOT</table>
	</from>
	<attrs>
		<attr>PART_USAGE.*</attr>
		<attr>PART_USAGE_LOT.*</attr>
	</attrs>
	<where>
		<data_constraint>
			<constraint>
				<left_operand>PART_USAGE.TASK_ID</left_operand>
				<operator>eq</operator>
				<right_operand>{TASK_ID}</right_operand>
			</constraint>
			<constraint>
				<left_operand>PART_USAGE.part_line_code</left_operand>
				<operator>ne</operator>
				<right_operand>C_PDO</right_operand>
			</constraint>
		</data_constraint>
		<join_constraint>
			<constraint>
				<left_operand>PART_USAGE.PU_ID</left_operand>
				<operator>left_outer</operator>
				<right_operand>PART_USAGE_LOT.PU_ID</right_operand>
			</constraint>
		</join_constraint>
	</where>
</hierarchy_select>

they don’t give the expected result.

 

Do you know how to achieve it?

 

Thanks in advance.

 

Cheers,

~Juni

3 replies

Shneor Cheshin
Superhero (Employee)
Forum|alt.badge.img+28
  • Superhero (Employee)
  • 1131 replies
  • May 2, 2024

Hi @JuniSihombing 

It is possible that part_usage is configured in another sync rule and the update is coming from there.

Run the following to search for suspects

select table_name
from mm_process_def
where (initial_query like '%part_usage%' or related_info_query like '%part_usage%')

Cheers!


JuniSihombing
Hero (Customer)
Forum|alt.badge.img+11
  • Author
  • Hero (Customer)
  • 130 replies
  • May 3, 2024

Hi @Shneor Cheshin ,

 

thank you for the response.

 

I have checked the sync rules which are using part_usage table.  The  sync is from part_usage sync rule (as the Initial Query works).  

 

FYI, the C_PDO part_usage is created from a custom screen to create Part Disposition > set to a specific disposition code (C_PR_SHIPMENT).

When this part-disposition is added, a custom script C_DPD_ADD will be called to create C_PDO part-usage.

//start
if (initialValuesHaveChanged())
{
	var partId = getControlValue("part_disp","part_id");
	var personId = getUserInfo('PersonID');
	var taskId = getCurrentKeys("task", "task_id");
	var quantity = getControlValue("part_disp", "quantity");

	var primaryKey = generatePrimaryKey('part_usage');
	setCurrentKeys("part_usage","pu_id",primaryKey);
	setControlValue('part_disp','pu_id',primaryKey);

	var partUsgTrans = generateDataTransaction("part_usage", "INSERT", "");
	partUsgTrans = addToDataTransaction(partUsgTrans, "pu_id", primaryKey);
	partUsgTrans = addToDataTransaction(partUsgTrans, "part_line_code", "C_PDO");
	partUsgTrans = addToDataTransaction(partUsgTrans, "person_id", personId);
	partUsgTrans = addToDataTransaction(partUsgTrans, "part_id", partId);
	partUsgTrans = addToDataTransaction(partUsgTrans, "task_id", taskId);
	partUsgTrans = addToDataTransaction(partUsgTrans, "quantity", quantity);
	var result = saveDataTransaction(partUsgTrans,'Part Usage Trans');

	if(saveChanges(false,false,false)){
		goToScreen('cDebriefPartDisposition');
	}
}
//end

 

Will the above requirement be able to achieve if the part_usage is created from mobile (using client script), or the part-usage should be created using Business Rules?

 

Cheers,

~Juni


Shneor Cheshin
Superhero (Employee)
Forum|alt.badge.img+28
  • Superhero (Employee)
  • 1131 replies
  • May 7, 2024
JuniSihombing wrote:

Will the above requirement be able to achieve if the part_usage is created from mobile (using client script), or the part-usage should be created using Business Rules?

 

Cheers,

~Juni

 

Hi @JuniSihombing 

Sorry, but I did not follow your question. Can you please rephrase?

Cheers!


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings