How to copy richtextbox value from one entity to another entity type?
Hello All,
Scenario: There is an Entity as "ContentBlock" (whereusedrelation) and product (owned relation).
In Content Block, we have an description attribute (datatype: richtextbox) similar we have the same attribute and datatype in product.
Sample Data stored in description of Content Block
This thgproductname has thgheight height and thgdiameter diameter.
- Test HUBER Rotary Drum Fine Screen ROTAMAT® Ro2 / RPPS / STAR
How it has to store the value in product description
This 3D-Printer antiC has 20cm height and 30cm diameter.
- Test HUBER Rotary Drum Fine Screen ROTAMAT® Ro2 / RPPS / STAR
Requirement is we want to copy description attribute value from CB to product along with changing the variable name as shown above.
During BR implementation we are facing issue and one or the other not able to display the whole value so need suggestion on how to implement this scenario.
Let me know for any query
-
Hi Kajal,
Can you share your BR here , and exactly what issue you faced while coping ?
and what is the below statement for , both of them looked same to me. is it a hardcoded line or something ?
- Test HUBER Rotary Drum Fine Screen ROTAMAT® Ro2 / RPPS / STAR
0 -
Hi Kajal, yes, can you please share the BR and the exact issue?
Also, please note that "RichTextBox" is not a data type, it is a display type, the data type is (or should be) "String".
Regarding the changing of the variable names (place holders), you will most likely need to do something like:
varString:="This thgproductname has thgheight height and thgdiameter diameter.";
varNewString:="";
SetVariable
[
"varNewString",
Replace[varString, "thgproductname", "the new value goes here"]
]
AND
SetVariable
[
"varNewString",
Replace[varNewString, "thgheight", "the new value goes here"]
]
... etc0 -
Hello Archna, Eric
Thanks for the response!
Archana: RickTextbox can hold any static value, I provided some random text.
Eric: Yes i tried the same logic.
Describing the issue in a Brief
Height is an UOM attribute and UOM Contains value and unit so in the system i was only able to see the height value and the rest of the text along with UOM it was getting stored in UOM. For better understanding i have attached the screenshot.
Mentioned the Business Rule.
varthgproductname:=GetAttributeValue["_DEFAULT","_DEFAULT","thgproductname"];
varthgheight:=GetAttributeValue["_DEFAULT","_DEFAULT","thgheight"];
varentityid:=GetRelatedEntityId["iscontentblockof","contentblock"];
vartxtdescriptioncb:=GetEntityAttributeValuesById["_DEFAULT","_DEFAULT",varentityid,"contentblock","txtdescription"];
varthgproductnamereplace:=Replace[vartxtdescriptioncb,"thgproductname",varthgproductname];
varthgproductnamereplace:=Replace[varthgproductnamereplace,"thgheight",varthgheight];
SetAttributeValue["_DEFAULT","_DEFAULT","txtdescription",varthgproductnamereplace]Result of this BR
Hence, instead of using Getattributevalue for height attr, we have to use ExtractUOMInfo and try out whats the outcome of this BR...
0 -
Hello Kajal
You are misusing the variable declarations.
The following needs to change:
varthgproductnamereplace:=Replace[vartxtdescriptioncb,"thgproductname",varthgproductname];
varthgproductnamereplace:=Replace[varthgproductnamereplace,"thgheight",varthgheight];You can't (or shouldn't declare the same variable twice).
You need to do something like:
varthgproductnamereplace:=Replace[vartxtdescriptioncb,"thgproductname",varthgproductname];
SetVariable["varthgproductnamereplace", Replace[varthgproductnamereplace,"thgheight",varthgheight]
AND
SetAttributeValue[ ... etc ... ]Regards
1 -
Hello Eric,
According to the given suggestion, I tried out and its the same outcome.
Simply i have changed the BR in 2 ways and check the result
1) Updated the BR and its results
varthgproductnamereplace:=Replace[vartxtdescriptioncb,"thgproductname",varthgproductname];
SetVariable["varthgproductnamereplace", Replace[varthgproductnamereplace,"thgheight",varthgheight] AND
SetAttributeValue["_DEFAULT","_DEFAULT","txtdescription",varthgproductnamereplace]]Result:
2) Updated the BR and its results
varthgproductnamereplace:=Replace[vartxtdescriptioncb,"thgproductname",varthgproductname];
SetVariable["varthgproductnamereplace", Replace[varthgproductnamereplace,"thgheight",varthgheight]] AND
SetAttributeValue["_DEFAULT","_DEFAULT","txtdescription",varthgproductnamereplace]Result:
0 -
Hello Eric,
Below is the BR which is Working fine as expected
varattributelist:="thgproductname||thgheight||thgproductnumber";
varthgproductname:=GetAttributeValue["_DEFAULT","_DEFAULT","thgproductname"];
varthgproductnumber:=GetAttributeValue["_DEFAULT","_DEFAULT","thgproductnumber"];
varthgheight:=ExtractUOMInfo[GetAttributeValue["_DEFAULT","_DEFAULT","thgheight"],"VALUE"];
varthgheightuom:=ExtractUOMInfo[GetAttributeValue["_DEFAULT","_DEFAULT","thgheight"],"UOM"];
varconcat:=Concat[varthgheight,"",varthgheightuom];
varentityid:=GetRelatedEntityId["iscontentblockof","contentblock"];
vartxtdescriptioncb:=GetEntityAttributeValuesById["_DEFAULT","_DEFAULT",varentityid,"contentblock","txtdescription"];
varthgproductnamereplace:=Replace[vartxtdescriptioncb,"thgproductname",varthgproductname];
varthgproductnamereplace:=Replace[varthgproductnamereplace,"thgheight",varconcat];
varthgproductnamereplace:=Replace[varthgproductnamereplace,"thgproductnumber",varthgproductnumber];
SetAttributeValue["_DEFAULT","_DEFAULT","txtdescription",varthgproductnamereplace]Final Result of Product Description
Content Block Description
Thanks for your Support and Response!
0 -
Hello Kajal,
Once again, the BR that you claim is working fine ... doesn't look right.
Unless Syndigo have changed how variables are defined and work, that BR is not using variables correctly.
Please take a closer look at the code I provided above ... I used the keyword "SetVariable" to update a variable, you are not doing that! The symbol := is used to declare a variable and assign an initial value, it shouldn't be used to assign a new value to an existing variable.
I would strongly recommend that you look up the documentation for "SetVariable" to see how that should be used.
If you require advanced assistance, maybe our company's should get in contact - we have many developers with years of experience with the Syndigo platform.
0 -
Hello Eric,
I have gone through the "SetVariable" keyword. It is not mention that we can't use existing variable to store multiple value.
I completely agree, the symbol := is used to declare a new variable.
If its not recommened, i will definitly change the syntax as per your suggestion!
0 -
I have changed the syntax.
SetVariable["varthgproductnamereplace",
Replace[varthgproductnamereplace,"thgheight",varconcat]] AND
SetVariable["varthgproductnamereplace",
Replace[varthgproductnamereplace,"thgproductnumber",varthgproductnumber]]Thanks!
0 -
Hello Kajal
Can you confirm whether or not the last changes worked? If it did work, confirming what the solution is/was might help other users in the future - maybe provide an "up-vote" to the comments that helped?
Thanks
0 -
Hello Eric,
Changes we performed related to Setvariable has worked as expected and below is the BR.
varattributelist:="thgproductname||thgheight||thgproductnumber";
varthgproductname:=GetAttributeValue["_DEFAULT","_DEFAULT","thgproductname"];
varthgproductnumber:=GetAttributeValue["_DEFAULT","_DEFAULT","thgproductnumber"];
varthgheight:=ExtractUOMInfo[GetAttributeValue["_DEFAULT","_DEFAULT","thgheight"],"VALUE"];
varthgheightuom:=ExtractUOMInfo[GetAttributeValue["_DEFAULT","_DEFAULT","thgheight"],"UOM"];
varconcat:=Concat[varthgheight,"",varthgheightuom];
varentityid:=GetRelatedEntityId["iscontentblockof","contentblock"];
vartxtdescriptioncb:=GetEntityAttributeValuesById["_DEFAULT","_DEFAULT",varentityid,"contentblock","txtdescription"];
varthgproductnamereplace:=Replace[vartxtdescriptioncb,"thgproductname",varthgproductname];
SetVariable["varthgproductnamereplace",
Replace[varthgproductnamereplace,"thgheight",varconcat]] AND
SetVariable["varthgproductnamereplace",
Replace[varthgproductnamereplace,"thgproductnumber",varthgproductnumber]] ANDSetAttributeValue["_DEFAULT","_DEFAULT","txtdescription",varthgproductnamereplace]
Thanks
1
Please sign in to leave a comment.
Comments
11 comments